#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t = 1;
  while (t--) {
    long long int i, n, x, y, j;
    cin >> n;
    vector<long long int> a;
    map<long long int, long long int> right, left;
    long long int ans = 0;
    for (i = 0; i < n; i++) {
      cin >> x >> y;
      right[x - y]++;
      left[x + y]++;
    }
    for (auto x : left) {
      ans += (x.second * (x.second - 1)) / 2;
    }
    for (auto x : right) {
      ans += (x.second * (x.second - 1)) / 2;
    }
    cout << ans << endl;
  }
}
