#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, a, b, s = 0;
  cin >> n;
  map<int, int> m1, m2;
  for (i = 1; i < n + 1; ++i) {
    int a, b;
    cin >> a >> b;
    s += m1[a + b]++;
    s += m2[a - b]++;
  }
  cout << s;
}
