#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, sum = 0, x = 0, y = 0;
  string s;
  cin >> n;
  vector<int> v1(2 * 1000 - 1);
  vector<int> v2(2 * 1000 - 1);
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    v1[x + y - 1]++;
    if (x - y >= 0)
      v2[x - y]++;
    else
      v2[1000 - 1 - (x - y)]++;
  }
  for (auto x : v1) sum = sum + x * (x - 1) / 2;
  for (auto x : v2) sum = sum + x * (x - 1) / 2;
  cout << sum;
  return 0;
}
