#include <bits/stdc++.h>
using namespace std;
long long int a[1000001];
long long int x[1000001], y[1000001];
map<int, int> mp[1002];
vector<int> v[110000], v2[110000];
int main() {
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    mp[x[i]][y[i]] = i + 1;
  }
  for (long long int i = 0; i < n; ++i) {
    v[y[i] - x[i] + 100000].push_back(mp[x[i]][y[i]]);
    v2[y[i] + x[i]].push_back(mp[x[i]][y[i]]);
  }
  long long int ans = 0;
  for (long long int i = 0; i < 110000; ++i) {
    if (v[i].size() == 0 || v[i].size() == 1)
      ;
    else
      ans += ((v[i].size()) * (v[i].size() - 1)) / 2;
    if (v2[i].size() == 0 || v2[i].size() == 1)
      ;
    else
      ans += ((v2[i].size()) * (v2[i].size() - 1)) / 2;
  }
  cout << ans << endl;
}
