#include <bits/stdc++.h>
using namespace std;
map<int, long long> mp, mp2;
int main() {
  ios ::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int r, c;
    cin >> r >> c;
    mp[r + c]++;
    mp2[r - c]++;
  }
  long long ans = 0;
  for (auto var : mp) {
    ans += var.second * (var.second - 1) / 2;
  }
  for (auto var : mp2) {
    ans += var.second * (var.second - 1) / 2;
  }
  cout << ans;
}
