#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
long long n;
long long x[maxn];
long long y[maxn];
long long dp[maxn][2];
int main() {
  while (~scanf("%I64d", &n)) {
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++) {
      scanf("%I64d%I64d", &x[i], &y[i]);
      x[i]--;
      y[i]--;
      long long b1 = y[i] - x[i] + 1000;
      long long b2 = y[i] + x[i];
      dp[b1][1]++;
      dp[b2][0]++;
    }
    long long sum = 0;
    for (int i = 0; i <= 2000; i++) {
      if (dp[i][1] >= 2) sum += dp[i][1] * (dp[i][1] - 1) / 2;
    }
    for (int i = 0; i <= 2000; i++) {
      if (dp[i][0] >= 2) sum += dp[i][0] * (dp[i][0] - 1) / 2;
    }
    printf("%I64d\n", sum);
  }
  return 0;
}
