3102 - Sgu512 Friendly Points

Consider n distinct points on a plane.

Two points from that set are said to be friends, when there exists a rectangle with sides parallel to coordinate axes that contains those two points and doesn't contain any other point from the given set. A rectangle is said to contain a point if the point lies within the rectangle or on its border.

How many pairs of friends are there among the given points? 求这样的点对个数:以两点连线为对角线的矩形内不存在其他点(也不能在边界上)

输入

The first line of the input file contains an integer n,1<=N<=100 000.

The next n lines contain two integers each, the coordinates of the given points. The coordinates don't exceed 109 by absolute value.

输出

Output one integer number — the sought number of pairs of friends.

样例

输入

5
0 0
0 2
2 0
2 2
1 1

输出

8
时间限制 1 秒
内存限制 128 MB
讨论 统计
上一题 下一题