#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
long long a[1010][1010];
long long xxx(long long x) { return x * (x - 1) / 2; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, ans = 0;
  cin >> n;
  while (n--) {
    long long x, y;
    cin >> x >> y;
    a[x][y] = 1;
  }
  for (long long i = 1; i <= 1000; i++) {
    long long j = 1, p = i, x = 0;
    while (p <= 1000 && j <= 1000)
      if (a[p++][j++]) x++;
    ans += xxx(x);
    p = i, j = 1, x = 0;
    while (p && j <= 1000)
      if (a[p--][j++]) x++;
    ans += xxx(x);
  }
  for (long long j = 2; j <= 1000; j++) {
    long long i = 1, p = j, x = 0;
    while (i <= 1000 && p <= 1000)
      if (a[i++][p++]) x++;
    ans += xxx(x);
    i = 1000, p = j, x = 0;
    while (i && p <= 1000)
      if (a[i--][p++]) x++;
    ans += xxx(x);
  }
  cout << ans;
  return 0;
}
