Problems
Segments
Segments
n segments [a_i, b_i] are given on a coordinate line. Find the number of pairs (i, j) such that i < j and segments [a_i, b_i] and [a_j, b_j] have at least one common point.
Input data
The first line contains an integer n (1 ≤ n ≤ 10^5). Each of the next n lines contains numbers a_i and b_i - the end points of a corresponding segment (-10^9 ≤ a_i, b_i ≤ 10^9).
Output data
Print the number of pairs of intersecting segments.
Examples
Input example #1
3 0 1 1 2 2 3
Output example #1
2
Input example #2
4 0 6 2 3 1 4 5 7
Output example #2
4