#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} a[200005];
int z[200001] = {0}, f[200001] = {0};
int aa[1005][1005];
int main() {
  int n;
  while (cin >> n) {
    memset(aa, 0, sizeof(aa));
    memset(z, 0, sizeof(z));
    memset(f, 0, sizeof(f));
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &a[i].x, &a[i].y);
      aa[a[i].x][a[i].y] = 1;
    }
    for (int i = 1; i <= n; i++) {
      int j;
      for (j = 1;; j++) {
        if (a[i].x + j > 1000 || a[i].y + j > 1000) break;
        if (aa[a[i].x + j][a[i].y + j] == 1) f[i]++;
      }
      for (j = 1;; j++) {
        if (a[i].x - j <= 0 || a[i].y - j <= 0) break;
        if (aa[a[i].x - j][a[i].y - j] == 1) f[i]++;
      }
      for (j = 1;; j++) {
        if (a[i].x + j > 1000 || a[i].y - j <= 0) break;
        if (aa[a[i].x + j][a[i].y - j] == 1) z[i]++;
      }
      for (j = 1;; j++) {
        if (a[i].x - j <= 0 || a[i].y + j > 1000) break;
        if (aa[a[i].x - j][a[i].y + j] == 1) z[i]++;
      }
      aa[a[i].x][a[i].y] = 0;
    }
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
      sum += z[i];
      sum += f[i];
    }
    printf("%I64d\n", sum);
  }
  return 0;
}
