#include <bits/stdc++.h>
using namespace std;
const int MaxN = 3e6 + 17;
const int INF = 1e9 + 17;
long long u1[MaxN], u2[MaxN], x, y, n, X1, Y1, X2, Y2;
long long Sum;
int main() {
  scanf("%I64d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d%I64d", &x, &y);
    int X = 1011 + x - y;
    Sum += u1[X];
    u1[X]++;
    int Y = y + x;
    Sum += u2[Y];
    u2[Y]++;
  }
  printf("%I64d", Sum);
  return 0;
}
