#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int md = 1e9 + 7;
long long pow(long long x, long long y) {
  long long r = 1;
  while (y) {
    if (y % 2 == 1) r *= x;
    x *= x;
    y /= 2;
  }
  return r;
}
long long gcd(long long x, long long y) {
  if (!y) return x;
  return (y, x % y);
}
int main() {
  int n, x, y, a, b;
  long long res = 0;
  scanf("%d", &n);
  map<int, int> mp1, mp2;
  for (int i = int(0); i < int(n); i++) {
    scanf("%d%d", &a, &b);
    x = a - b;
    y = a + b;
    if (mp1.find(x) != mp1.end())
      mp1[x] = mp1[x] + 1;
    else
      mp1[x] = 1;
    if (mp2.find(y) != mp2.end())
      mp2[y] = mp2[y] + 1;
    else
      mp2[y] = 1;
  }
  map<int, int>::iterator it;
  for (it = mp1.begin(); it != mp1.end(); it++) {
    res += ((it->second) * (it->second - 1)) / 2;
  }
  for (it = mp2.begin(); it != mp2.end(); it++) {
    res += ((it->second) * (it->second - 1)) / 2;
  }
  cout << res;
  return 0;
}
