#include <bits/stdc++.h>
using namespace std;
map<int, int> p, q;
int main() {
  int n, i, x, y;
  cin >> n;
  long long ans = 0;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    ans += p[x + y] + q[x - y];
    p[x + y]++, q[x - y]++;
  }
  cout << ans << endl;
}
