#include <bits/stdc++.h>
using namespace std;
map<int, int> cnt1, cnt2;
const int maxn = 1e5 * 3;
int x[maxn];
int y[maxn];
int main() {
  int n = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    cnt1[x[i] - y[i]]++;
    cnt2[x[i] + y[i]]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long c1 = cnt1[x[i] - y[i]];
    long long c2 = cnt2[x[i] + y[i]];
    ans += c1 + c2 - 2;
  }
  cout << ans / 2;
}
