#include <bits/stdc++.h>
int map[1010][1010];
int main() {
  int n, x, y, m, mx, my, px, py, k;
  long long sum;
  while (~scanf("%d", &n)) {
    m = sum = px = py = 0;
    memset(map, 0, sizeof(map));
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &x, &y);
      px = px > x ? px : x;
      py = py > y ? py : y;
      map[x][y] = 1;
    }
    if (n == 1) {
      printf("0\n");
      continue;
    }
    k = px > py ? px : py;
    for (int i = 1; i <= k; i++) {
      for (int j = 1; j <= k; j++) {
        if (map[i][j]) {
          m++;
          mx = i + 1;
          my = j + 1;
          while (mx <= k && my <= k) {
            if (map[mx][my]) sum++;
            mx++;
            my++;
          }
        }
        if (m == n) break;
      }
      if (m == n) break;
    }
    m = 0;
    for (int i = k; i >= 1; i--) {
      for (int j = k; j >= 1; j--) {
        if (map[i][j]) {
          m++;
          mx = i - 1;
          my = j + 1;
          while (mx >= 1 && my <= k) {
            if (map[mx][my]) sum++;
            mx--;
            my++;
          }
        }
        if (m == n) break;
      }
      if (m == n) break;
    }
    printf("%I64d\n", sum);
  }
  return 0;
}
