#include <bits/stdc++.h>
using namespace std;
bool a[1001][1001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    a[u][v] = 1;
  }
  long long ans = 0;
  map<long long, long long> m;
  for (int i = 1; i <= 1000; i++) {
    for (int j = 1; j <= 1000; j++) {
      if (a[i][j]) m[i + j]++;
    }
  }
  for (auto x : m) {
    ans += (x.second * (x.second - 1)) / 2;
  }
  m.clear();
  for (int i = 1; i <= 1000; i++) {
    for (int j = 1; j <= 1000; j++) {
      if (a[i][j]) m[i - j]++;
    }
  }
  for (auto x : m) {
    ans += (x.second * (x.second - 1)) / 2;
  }
  cout << ans;
  return 0;
}
