#include <bits/stdc++.h>
using namespace std;
int arr[1001][1001];
int main() {
  long long int n, sum = 0, count = 0, x, y, z, i;
  scanf("%lld", &n);
  while (n--) {
    cin >> x >> y;
    arr[x][y] = 1;
  }
  for (i = 1; i <= 1000; i++) {
    count = 0;
    y = 1;
    z = i;
    while (1) {
      if (y > 1000 || z > 1000) break;
      x = arr[y][z];
      count += x;
      y++;
      z++;
    }
    sum += (((count) * (count - 1)) / 2);
  }
  for (i = 1; i <= 1000; i++) {
    count = 0;
    y = 1;
    z = i;
    while (1) {
      if (y > 1000 || z < 1) break;
      x = arr[y][z];
      count += x;
      y++;
      z--;
    }
    sum += (((count) * (count - 1)) / 2);
  }
  for (i = 2; i <= 1000; i++) {
    count = 0;
    y = i;
    z = 1000;
    while (1) {
      if (y > 1000 || z < 1) break;
      x = arr[y][z];
      count += x;
      y++;
      z--;
    }
    sum += (((count) * (count - 1)) / 2);
  }
  for (i = 2; i <= 1000; i++) {
    count = 0;
    y = i;
    z = 1;
    while (1) {
      if (y > 1000 || z > 1000) break;
      x = arr[y][z];
      count += x;
      y++;
      z++;
    }
    sum += (((count) * (count - 1)) / 2);
  }
  printf("%lld\n", sum);
  return 0;
}
