#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
void solve() {
  int n;
  cin >> n;
  map<int, int> m1, m2;
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    s += m1[a + b]++;
    s += m2[a - b]++;
  }
  cout << s;
}
