#include <bits/stdc++.h>
using namespace std;
int main() {
  long long b[3000] = {0}, n, a, x, i, c[3000] = {0};
  set<pair<long long, long long> > myset;
  cin >> n;
  long long ans = 0;
  for (i = 0; i < n; i++) {
    cin >> a >> x;
    myset.insert({a, x});
    b[a + x]++;
    if (a - x < 0) {
      c[1100 + abs(a - x) - 1]++;
    } else
      c[a - x]++;
  }
  for (i = 2; i <= 2500; i++) ans += b[i] * (b[i] - 1) / 2;
  for (i = 0; i <= 2500; i++) ans += c[i] * (c[i] - 1) / 2;
  cout << ans << "\n";
  return 0;
}
