#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const double eps = 1e-11;
const int inf = (int)2e9;
const int mod = (int)1e9 + 7;
map<int, int> num;
map<int, int> used;
long long n;
long long x, y;
long long i, ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    ans += used[y - x]++;
    ans += num[y + x]++;
  }
  printf("%d", ans);
}
