#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > points(n);
  map<int, int> diag, anti;
  for (int i = 0; i < n; i++) {
    cin >> points[i].first >> points[i].second;
    diag[points[i].first + points[i].second]++;
    anti[points[i].first - points[i].second]++;
  }
  long long total = 0;
  for (auto p : points) {
    int x = p.first, y = p.second;
    total += diag[x + y] - 1;
    total += anti[x - y] - 1;
  }
  total /= 2;
  cout << total << endl;
  return 0;
}
