#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, kq = 0;
  map<int, int> m;
  map<int, int> m1;
  map<int, int>::iterator it;
  pair<int, int> a[200100];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
    m[a[i].first - a[i].second]++;
    m1[a[i].first + a[i].second]++;
  }
  for (it = m.begin(); it != m.end(); it++)
    kq += (it->second) * (it->second - 1) / 2;
  for (it = m1.begin(); it != m1.end(); it++)
    kq += (it->second) * (it->second - 1) / 2;
  cout << kq;
}
