#include <bits/stdc++.h>
using namespace std;
int fr() {
  char ch;
  int t = 0, flag = 0;
  ch = getchar();
  while (ch < 33) ch = getchar();
  if (ch == '-') {
    ch = getchar();
    flag = 1;
  }
  while (ch > 33) {
    t = t * 10 + ch - '0';
    ch = getchar();
  }
  if (flag)
    return -t;
  else
    return t;
}
int a[1001][1001] = {0};
int main() {
  int i, j, k, t, n, m, x, y;
  n = fr();
  long long ans = 0;
  for (i = 0; i < n; i++) {
    x = fr();
    y = fr();
    a[x][y] = 1;
  }
  for (i = 1; i <= 1000; i++) {
    for (j = i, k = 1, t = 0; j >= 1 && k <= 1000; j--, k++) {
      if (a[j][k]) t++;
    }
    ans += ((t) * (t - 1)) / 2;
  }
  for (j = 2; j <= 1000; j++) {
    for (i = 1000, t = 0, k = j; i >= 1 && k <= 1000; k++, i--) {
      if (a[i][k]) t++;
    }
    ans += ((t) * (t - 1)) / 2;
  }
  for (i = 1; i <= 1000; i++) {
    for (j = 1, k = i, t = 0; j <= 1000 && k <= 1000; j++, k++) {
      if (a[j][k]) t++;
    }
    ans += ((t) * (t - 1)) / 2;
  }
  for (i = 2; i <= 1000; i++) {
    for (j = i, k = 1, t = 0; j <= 1000 && k <= 1000; j++, k++) {
      if (a[j][k]) t++;
    }
    ans += ((t) * (t - 1)) / 2;
  }
  printf("%I64d", ans);
  return 0;
}
