#include <bits/stdc++.h>
using namespace std;
int n, x, y, alfilesEnDiagonal[2][1999];
unsigned long long int respuesta = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  while (n--) {
    cin >> x >> y;
    alfilesEnDiagonal[0][x + y - 2]++;
    alfilesEnDiagonal[1][x - y + 999]++;
  }
  for (int i = 0; i < 1999; i++) {
    respuesta += (alfilesEnDiagonal[0][i] - 1) * (alfilesEnDiagonal[0][i]) / 2;
    respuesta += (alfilesEnDiagonal[1][i] - 1) * (alfilesEnDiagonal[1][i]) / 2;
  }
  cout << respuesta << endl;
  return 0;
}
