#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int xs[200000], ys[200000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> xs[i] >> ys[i];
  }
  map<int, int> vert, hor;
  for (int i = 0; i < n; i++) {
    int x, y;
    x = xs[i];
    y = ys[i];
    int v = x - y + 1;
    int h = y + x - 1;
    int buf;
    buf = vert[v];
    vert[v] = buf + 1;
    buf = hor[h];
    hor[h] = buf + 1;
  }
  long long res = 0;
  for (map<int, int>::iterator it = vert.begin(); it != vert.end(); ++it) {
    long long buf = (long long)it->second;
    buf--;
    long long sum = (buf * buf + buf) / 2;
    res += sum;
  }
  for (map<int, int>::iterator it = hor.begin(); it != hor.end(); ++it) {
    long long buf = (long long)it->second;
    buf--;
    long long sum = (buf * buf + buf) / 2;
    res += sum;
  }
  cout << res;
}
