#include <bits/stdc++.h>
using namespace std;
const int MX = 200005;
int n, x[MX], y[MX];
map<pair<int, long long>, int> mp;
long long res = 0;
void obtRes() {
  mp.clear();
  for (int i = 0; i < n; i++) {
    int d = min(x[i], y[i]);
    pair<int, long long> p(x[i] - d, y[i] - d);
    res += mp[p];
    mp[p]++;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  obtRes();
  for (int i = 0; i < n; i++) x[i] = 1000 - x[i] + 1;
  obtRes();
  cout << res << '\n';
  return 0;
}
