#include <bits/stdc++.h>
using namespace std;
int a[1005][1005];
int main() {
  int cs, x, y;
  long long ans = 0;
  cin >> cs;
  for (int i = 0; i < cs; i++) {
    cin >> x >> y;
    a[x][y] = 1;
  }
  int i, j = 1, k = 1, n = 1000;
  while (k <= n) {
    j = k;
    i = 1;
    long long cnt = 0;
    while (i <= n - k + 1) {
      if (a[i][j] == 1) cnt++;
      i++;
      j++;
    }
    k++;
    ans += (cnt * (cnt - 1)) / 2;
  }
  k = 2;
  while (k <= n) {
    i = k;
    j = 1;
    long long cnt = 0;
    while (i <= n) {
      if (a[i][j] == 1) cnt++;
      i++;
      j++;
    }
    k++;
    ans += (cnt * (cnt - 1)) / 2;
  }
  k = 1;
  while (k <= n) {
    long long cnt = 0;
    i = 1;
    j = k;
    while (j >= 1) {
      if (a[i][j] == 1) cnt++;
      i++;
      j--;
    }
    k++;
    ans += (cnt * (cnt - 1)) / 2;
  }
  k = 2;
  while (k <= n) {
    long long cnt = 0;
    j = n;
    i = k;
    while (i <= n) {
      if (a[i][j] == 1) cnt++;
      i++;
      j--;
    }
    k++;
    ans += (cnt * (cnt - 1)) / 2;
  }
  cout << ans << "\n";
  return 0;
}
