#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
  ll n;
  cin >> n;
  vector<ll> v1(n + 10000);
  vector<ll> v2(n + 10000);
  for (int i = 0; i < n; ++i) {
    ll a;
    ll b;
    cin >> a >> b;
    v1[3000 + a - b]++;
    v2[3000 + (2000 - a) - b]++;
  }
  ll sum = 0;
  for (auto elem : v1) {
    sum += elem * (elem - 1) / 2;
  }
  for (auto elem : v2) {
    sum += elem * (elem - 1) / 2;
  }
  cout << sum << endl;
}
