#include <bits/stdc++.h>
using namespace std;
int N, a[100005];
int t[1005][1005];
bool chk[1005][1005][5];
int id[1005][1005];
int lid = 0;
vector<pair<int, int> > p;
int x[200005], y[200005];
long long ans = 0;
void bs(int r, int c) {
  if (chk[r][c][0] == 0) {
    int tmp = 0;
    for (int i = r, j = c; i <= 1000 && j <= 1000; i++, j++) {
      if (t[i][j]) {
        tmp++;
        chk[i][j][0] = true;
      }
    }
    ans += (tmp * (tmp - 1)) / 2;
  }
  if (chk[r][c][1] == 0) {
    int tmp = 0;
    for (int i = r, j = c; i <= 1000 && j >= 1; i++, j--) {
      if (t[i][j]) {
        tmp++;
        chk[i][j][1] = true;
      }
    }
    ans += (tmp * (tmp - 1)) / 2;
  }
  if (chk[r][c][2] == 0) {
    int tmp = 0;
    for (int i = r, j = c; i >= 1 && j <= 1000; i--, j++) {
      if (t[i][j]) {
        tmp++;
        chk[i][j][2] = true;
      }
    }
  }
  if (chk[r][c][3] == 0) {
    int tmp = 0;
    for (int i = r, j = c; i >= 1 && j >= 1; i--, j--) {
      if (t[i][j]) {
        tmp++;
        chk[i][j][3] = true;
      }
    }
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d%d", &x[i], &y[i]);
    t[x[i]][y[i]] = 1;
    p.push_back(make_pair(x[i], y[i]));
  }
  for (int i = 1; i <= 1000; i++) {
    for (int j = 1; j <= 1000; j++) {
      if (t[i][j] != 0) bs(i, j);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
