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