#include <bits/stdc++.h>
using namespace std;
int m = 1000;
long long f(long long x) { return x * (x - 1) / 2; }
bool comp(int x, int y) {
  if (x >= 0 and x < m and y >= 0 and y < m) return 1;
  return 0;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int x[n], y[n];
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  int board[m + 5][m + 5];
  memset(board, 0, sizeof(board));
  for (int i = 0; i < n; i++) {
    x[i]--;
    y[i]--;
    board[x[i]][y[i]] = 1;
  }
  long long ans = 0;
  bool flag = 1;
  int i = 0, j = 0;
  while (1) {
    if (i == m) break;
    if (j == m) {
      j = m - 1;
      i++;
      flag = 0;
    }
    long long cnt = 0;
    int tempi = i, tempj = j;
    while (comp(tempi, tempj)) {
      if (board[tempi][tempj]) cnt++;
      tempi++;
      tempj--;
    }
    if (flag)
      j++;
    else
      i++;
    ans += f(cnt);
  }
  i = m - 1, j = 0;
  flag = 1;
  while (1) {
    if (j == m) break;
    if (i == -1) {
      i = 0;
      j = 1;
      flag = 0;
    }
    long long cnt = 0;
    int ti = i, tj = j;
    while (comp(ti, tj)) {
      if (board[ti][tj]) cnt++;
      ti++;
      tj++;
    }
    if (flag)
      i--;
    else
      j++;
    ans += f(cnt);
  }
  cout << ans;
  return 0;
}
