#include <bits/stdc++.h>
using namespace std;
map<int, int> freq, freq2;
map<int, int>::iterator it;
long long apsum(long long n) { return ((n + 1LL) * n) / 2LL; }
int main() {
  int n, r, c;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &r, &c);
    freq[r - c]++;
    freq2[r + c]++;
  }
  long long ans = 0;
  for (it = freq.begin(); it != freq.end(); ++it)
    ans += apsum((*it).second - 1);
  for (it = freq2.begin(); it != freq2.end(); ++it)
    ans += apsum((*it).second - 1);
  printf("%lld\n", ans);
  return 0;
}
