import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Northwest { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; while ((line = br.readLine()) != null && !line.isEmpty()) { int townsNo = Integer.parseInt(line); int[][] towns = new int[townsNo][2]; for (int i = 0; i < townsNo; i++) { StringTokenizer st = new StringTokenizer(br.readLine()); towns[i][0] = Integer.parseInt(st.nextToken()); towns[i][1] = Integer.parseInt(st.nextToken()); } double pairs = townsNo * townsNo; int winner = 0; for (int i = 0; i < townsNo - 1; i++) { for (int j = i + 1; j < townsNo; j++) { int[] town1 = towns[i]; int[] town2 = towns[j]; if (Math.abs(town1[0] - town2[0]) == Math.abs(town1[1] - town2[1])){ winner += 2; } } } System.out.println(winner/pairs); } } }