// Arup Guha
// 12/28/2020
// Solution to 2020 Dec USACO Silver Problem: Rectangular Pasture

import java.util.*;

public class pasture {
	
	public static void main(String[] args) {
	
		// Read in points initially, store x's, y's to coordinate compress.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		
		// Store x's y's here.
		TreeSet<Integer> xList = new TreeSet<Integer>();
		TreeSet<Integer> yList = new TreeSet<Integer>();
	
		// Read in points.
		for (int i=0; i<n; i++) {
			x[i] = stdin.nextInt();
			y[i] = stdin.nextInt();
			xList.add(x[i]);
			yList.add(y[i]);
		}
		
		// Coordinate compress.
		HashMap<Integer,Integer> xMap = getMap(xList);
		HashMap<Integer,Integer> yMap = getMap(yList);
		apply(xMap, x);
		apply(yMap, y);
		
		// Will be a 2D cumulative frequency array.
		int[][] cumfreq = new int[n+1][n+1];
		
		// I've shifted each term over by 1 for convenience of getting sums of rectangles.
		for (int i=0; i<n; i++)
			cumfreq[x[i]+1][y[i]+1]++;
			
		// This makes cumulative frequency by rows.
		for (int i=0; i<=n; i++)
			for (int j=1; j<=n; j++)
				cumfreq[i][j] += cumfreq[i][j-1];
				
		// Then this does it for rectangles.
		for (int j=0; j<=n; j++)
			for (int i=1; i<=n; i++)
				cumfreq[i][j] += cumfreq[i-1][j];
		
		// Store the result here - I already count the rectangles around each individual square.
		// and the empty rectangle.
		long res = n+1;
		
		// Now go by pairs of points - count each rectangle with x boundaries x[i] and x[j].
		for (int i=0; i<n; i++) {
			for (int j=i+1; j<n; j++) {
			
				// x boundaries and y boundaries of this box.
				int xMin = Math.min(x[i], x[j]);
				int xMax = Math.max(x[i], x[j]) + 1;
				int yMin = Math.min(y[i], y[j]);
				int yMax = Math.max(y[i], y[j]) + 1;
				
				// Count pts to left and right of this rectangle within this strip.
				long left = cumfreq[xMax][yMin] - cumfreq[xMin][yMin];
				long right = cumfreq[xMax][n] - cumfreq[xMin][n] - cumfreq[xMax][yMax] + cumfreq[xMin][yMax];
			
				//System.out.println("Aleft is "+left+" right is "+right);
				
				
				// These are ALL the rectangles that use these two pts as x boundaries.
				res += (left+1)*(right+1);
			}
		}
		
		// Ta da!
		System.out.println(res);
	}
	
	// Returns each value in list mapped to its 0 based rank.
	public static HashMap<Integer,Integer> getMap(TreeSet<Integer> list) {
	
		// Set up the map.
		int i = 0;
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		
		// Pull out each item one by one.
		while (list.size() > 0) map.put(list.pollFirst(), i++);
		return map;
	}
	
	// Just replaces each value in arr with it's mapped value in map.
	public static void apply(HashMap<Integer,Integer> map, int[] arr) {
		for (int i=0; i<arr.length; i++)
			arr[i] = map.get(arr[i]);
	}
}