#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, diff[5000], sum[5000], x, y;
  long long result = 0;
  for (int i = 0; i < 5000; i++) {
    diff[i] = 0;
    sum[i] = 0;
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    cin >> y;
    diff[x - y + 999] += 1;
    sum[x + y - 2] += 1;
  }
  for (int i = 0; i < 5000; i++) {
    if (diff[i] > 1) result += diff[i] * (diff[i] - 1) / 2;
    if (sum[i] > 1) result += sum[i] * (sum[i] - 1) / 2;
  }
  cout << result;
  return 0;
}
