#include <bits/stdc++.h>
using namespace std;
const int MAX = 4040;
map<int, int> cnt1;
map<int, int> cnt2;
pair<int, int> a[200020];
int main() {
  int ans = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    cnt1[a[i].first + a[i].second]++;
    cnt2[a[i].first - a[i].second]++;
  }
  for (int i = 0; i < n; i++) {
    int curx = a[i].first;
    int cury = a[i].second;
    ans += cnt2[curx - cury] - 1 + cnt1[curx + cury] - 1;
  }
  cout << ans / 2 << endl;
}
