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