#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n;
  cin >> n;
  vector<pair<unsigned long long, unsigned long long> > v(n);
  for (unsigned long long i = 0; i < n; i++) {
    scanf("%I64u %I64u", &v[i].first, &v[i].second);
  }
  vector<unsigned long long> d1(2001, 0), d2(2001, 0);
  for (unsigned long long i = 0; i < n; i++) {
    unsigned long long x = v[i].first;
    unsigned long long y = v[i].second;
    d1[x + y - 1]++;
    d2[1000 - x + y]++;
  }
  unsigned long long sum = 0;
  for (unsigned long long i = 0; i < 2001; i++) {
    if (d1[i] > 1) sum += d1[i] * (d1[i] - 1) / 2;
    if (d2[i] > 1) sum += d2[i] * (d2[i] - 1) / 2;
  }
  cout << sum << endl;
}
