#include <bits/stdc++.h>
using namespace std;
long a[1010][1010];
long ans[4500];
long cnt;
long long answ = 0LL;
long n;
long M;
int main() {
  M = -1;
  int k = 0;
  long x, y;
  scanf("%ld", &n);
  for (long i = 1; i <= n; i++) {
    scanf("%ld%ld", &x, &y);
    if (x > M) M = x;
    if (y > M) M = y;
    a[x][y] = 1;
  }
  for (long i = 1; i <= M; i++) {
    long z = 0;
    for (x = 1, y = i; x <= M && y <= M; x++, y++) {
      if (a[x][y]) z++;
    }
    if (z > 1) ans[++cnt] = z;
  }
  for (long i = 2; i <= M; i++) {
    long z = 0;
    for (x = 1, y = i; x <= M && y <= M; x++, y++) {
      if (a[y][x]) z++;
    }
    if (z > 1) ans[++cnt] = z;
  }
  for (long i = M; i >= 1; i--) {
    long z = 0;
    for (x = 1, y = i; x <= M && y >= 1; x++, y--) {
      if (a[x][y]) z++;
    }
    if (z > 1) ans[++cnt] = z;
  }
  for (long i = 2; i <= M; i++) {
    long z = 0;
    for (x = M, y = i; x >= 1 && y <= M; x--, y++) {
      if (a[y][x]) z++;
      k = 1;
    }
    if (z > 1) ans[++cnt] = z;
  }
  for (long i = 1; i <= cnt; i++) {
    long long a, b;
    a = ans[i];
    b = a - 1;
    answ += a * b / 2;
  }
  printf("%I64d\n", answ);
  return 0;
}
