#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long>> bish(n);
  for (long long i = 0; i < (n); ++i) {
    cin >> bish[i].first;
    cin >> bish[i].second;
  }
  map<long long, long long> left;
  map<long long, long long> right;
  for (long long i = 0; i < (n); ++i) {
    pair<long long, long long> temp = bish[i];
    temp.second -= temp.first;
    left[temp.second]++;
    temp = bish[i];
    temp.second -= 1000 - temp.first;
    right[temp.second]++;
  }
  long long result = 0;
  for (pair<long long, long long> p : left) {
    result += p.second * (p.second - 1) / 2;
  }
  for (pair<long long, long long> p : right) {
    result += p.second * (p.second - 1) / 2;
  }
  cout << result;
  return 0;
}
