There are $N$ scarecrows standing in a large wasteland in JOI Village. Several times a year, the villagers hold a festival surrounding the scarecrows. One day, the village chief of JOI Village, who claimed to have heard an oracle from the scarecrows, made a plan to build one field in the wasteland. According to the oracle, the field must satisfy the following conditions:
- It is a rectangle whose sides are parallel to the east-west or north-south directions.
- There is a scarecrow at the southwest vertex and at the northeast vertex.
- There are no scarecrows inside the field (excluding the boundaries).
Of course, it is not permitted to move the precious scarecrows. How many locations for the field are there that follow the oracle?
Task
Given the positions of the scarecrows, write a program to calculate the number of locations for the field that follow the oracle.
Input
Read the following data from standard input:
- The first line contains an integer $N$, representing that there are $N$ scarecrows.
- The $i$-th line of the following $N$ lines ($1 \le i \le N$) contains integers $X_i$ and $Y_i$ separated by a space. The wasteland of JOI Village is represented by an $xy$-coordinate plane, where the positive $x$-axis points east and the positive $y$-axis points north. The $i$-th scarecrow stands at coordinates $(X_i, Y_i)$.
Output
Output the number of locations for the field that follow the oracle in a single line.
Constraints
All input data satisfy the following conditions:
- $1 \le N \le 200\,000$.
- $0 \le X_i \le 1\,000\,000\,000$ ($1 \le i \le N$).
- $0 \le Y_i \le 1\,000\,000\,000$ ($1 \le i \le N$).
- $X_i$ ($1 \le i \le N$) are all distinct.
- $Y_i$ ($1 \le i \le N$) are all distinct.
Subtasks
Subtask 1 [5 points]
- $N \le 400$ is satisfied.
Subtask 2 [10 points]
- $N \le 5\,000$ is satisfied.
Subtask 3 [85 points]
- There are no additional constraints.
Examples
Input 1
4 0 0 2 2 3 4 4 3
Output 1
3
Note 1
In this example, the following 3 locations for the field (shown in the figures below) are possible:
- A rectangle with point $(0, 0)$ as the southwest vertex and point $(2, 2)$ as the northeast vertex.
- A rectangle with point $(2, 2)$ as the southwest vertex and point $(3, 4)$ as the northeast vertex.
- A rectangle with point $(2, 2)$ as the southwest vertex and point $(4, 3)$ as the northeast vertex.
Input 2
10 2 1 3 0 6 3 10 2 16 4 0 8 8 12 11 14 14 11 18 10
Output 2
15
Note 2
In this example, the scarecrows are standing as shown in the figure below.