#include <bits/stdc++.h>
long long c[2000][2000];
using namespace std;
int main() {
  int n;
  cin >> n;
  int x[n], y[n];
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  int a[3001];
  int b[3001];
  for (int i = 0; i <= 3000; i++) {
    a[i] = 0;
    b[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    a[x[i] - y[i] + 1000]++;
    b[x[i] + y[i]]++;
  }
  int ans = 0;
  for (int i = 0; i <= 3000; i++) {
    ans += a[i] * (a[i] - 1) / 2;
    ans += b[i] * (b[i] - 1) / 2;
  }
  cout << ans << "\n";
}
