#include <bits/stdc++.h>
using namespace std;
map<int, int> dx, dy;
int main() {
  int n, i, x, y, a, b;
  cin >> n;
  long long ret = 0;
  for (i = 0; i < n; ++i) {
    cin >> x >> y;
    a = 1 - x;
    b = y + a;
    ret += dx[b];
    dx[b]++;
    b = y - a;
    ret += dy[b];
    dy[b]++;
  }
  cout << ret << endl;
}
