#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  map<long long, long long> m;
  map<long long, long long> k;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    m[a + b]++;
    k[a - b]++;
  }
  long long sum = 0;
  if (m.size())
    for (auto i : m) {
      long long t = i.second;
      if (t > 1) sum += t * (t - 1) / 2;
    }
  if (k.size())
    for (auto j : k) {
      long long t = j.second;
      if (t > 1) sum += t * (t - 1) / 2;
    }
  cout << sum << "\n";
}
