#include <bits/stdc++.h>
using namespace std;
long long a[2002][2002];
signed main() {
  long long n;
  cin >> n;
  long long x, y;
  for (long long i = 1; i <= n; i++) {
    cin >> x >> y;
    a[x][y]++;
  }
  long long res = 0;
  for (long long k = 1; k <= 2000; k++) {
    long long sum = 0;
    for (long long i = 1; i <= k; i++) {
      long long j = k - i;
      if (j > 0 && j <= 1000) {
        sum += a[i][j];
      }
    }
    res += sum * (sum - 1) / 2;
  }
  for (long long i = 1; i <= 1000; i++) {
    long long sum = 0;
    long long pos1 = i;
    long long pos2 = 1000;
    sum += a[pos1][pos2];
    while (pos1 > 1 && pos2 > 1) {
      pos1--;
      pos2--;
      sum += a[pos1][pos2];
    }
    res += sum * (sum - 1) / 2;
  }
  for (long long i = 999; i >= 1; i--) {
    long long sum = 0;
    long long pos1 = 1000;
    long long pos2 = i;
    sum += a[pos1][pos2];
    while (pos1 > 1 && pos2 > 1) {
      pos1--;
      pos2--;
      sum += a[pos1][pos2];
    }
    res += sum * (sum - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
