#include <bits/stdc++.h>
using namespace std;
int X[] = {1, 0, -1, 0, 1, -1, -1, 1};
int Y[] = {0, 1, 0, -1, 1, 1, -1, -1};
void MN(long long int &a, long long int b) {
  if (a > b) a = b;
}
void MX(long long int &a, long long int b) {
  if (a < b) a = b;
}
void MN(int &a, int b) {
  if (a > b) a = b;
}
void MX(int &a, int b) {
  if (a < b) a = b;
}
long long int MOD(long long int a, long long int b) {
  return a >= 0 ? a % b : (b - abs(a % b)) % b;
}
int OneD(int row, int col, int t_n_o_r) { return row * t_n_o_r + col; }
int grid[1001][1001];
int valido(int x, int y) {
  if (x <= 0 || y <= 0 || x > 1000 || y > 1000)
    return 0;
  else
    return 1;
}
int main() {
  int n, x, y, res = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    grid[x][y] = 1;
  }
  for (int c, r = 2, R; r <= 1000; r++) {
    int cw = 0;
    c = 1;
    R = r;
    while (valido(R, c)) {
      if (grid[R][c]) cw++;
      R--;
      c++;
    }
    int m = cw - 1;
    res += (m * (m + 1) / 2);
  }
  for (int r, c = 2, C; c < 1000; c++) {
    int cw = 0;
    r = 1000;
    C = c;
    while (valido(r, C)) {
      if (grid[r][C]) cw++;
      r--;
      C++;
    }
    int m = cw - 1;
    res += (m * (m + 1) / 2);
  }
  for (int r, c = 1000 - 1, C; c >= 1; c--) {
    int cw = 0;
    r = 1;
    C = c;
    while (valido(r, C)) {
      if (grid[r][C]) cw++;
      r++;
      C++;
    }
    int m = cw - 1;
    res += (m * (m + 1) / 2);
  }
  for (int c, r = 2, R; r <= 1000; r++) {
    int cw = 0;
    c = 1;
    R = r;
    while (valido(R, c)) {
      if (grid[R][c]) cw++;
      R++;
      c++;
    }
    int m = cw - 1;
    res += (m * (m + 1) / 2);
  }
  printf("%d\n", res);
  return 0;
}
