#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
bool vis[maxn][maxn], vis_t[maxn][maxn];
int n, x, y;
long long ans = 0, cnt;
int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%d %d", &x, &y);
    vis[x][y] = true;
  }
  for (int i = 1; i <= 1000; ++i) {
    for (int j = 1; j <= 1000; ++j) {
      if (vis_t[i][j]) {
        continue;
      }
      x = i;
      y = j;
      cnt = 0;
      while (x <= 1000 && y >= 1) {
        if (vis[x][y]) {
          ++cnt;
        }
        ++x;
        --y;
        vis_t[x][y] = true;
      }
      ans += cnt * (cnt - 1) / 2;
    }
  }
  memset(vis_t, false, sizeof(vis_t));
  for (int i = 1; i <= 1000; ++i) {
    for (int j = 1; j <= 1000; ++j) {
      if (vis_t[i][j]) {
        continue;
      }
      x = i;
      y = j;
      cnt = 0;
      while (x <= 1000 && y <= 1000) {
        if (vis[x][y]) {
          ++cnt;
        }
        ++x;
        ++y;
        vis_t[x][y] = true;
      }
      ans += cnt * (cnt - 1) / 2;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
