#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> x(n + 1), y(n + 1);
  vector<int> xx(2005, 0), yy(2005, 0);
  map<int, int> s1, s2;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    s1[x[i] + y[i]]++;
    xx[x[i] + y[i]] = 1;
    s2[x[i] - y[i]]++;
    yy[x[i] - y[i] + 1000] = 1;
  }
  long long res = 0;
  for (int i = 1; i < 2005; i++) {
    if (xx[i] == 1) {
      res += ((s1[i] * (s1[i] - 1)) / 2);
    }
    if (yy[i] == 1) {
      res += ((s2[i - 1000] * (s2[i - 1000] - 1)) / 2);
    }
  }
  cout << res << endl;
  return 0;
}
