#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  map<long long, long long> md;
  map<long long, long long> sd;
  long long attack = 0;
  for (int i = 0; i < N; i++) {
    long long x, y;
    cin >> x >> y;
    attack += sd[(x + y)];
    attack += md[(x - y) + 1000];
    md[(x - y) + 1000]++;
    sd[x + y]++;
  }
  cout << attack << endl;
  return 0;
}
