#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int maze[1005][1005];
int main() {
  memset(maze, 0, sizeof(maze));
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    maze[x][y] += 1;
  }
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    int x = 1, y = i;
    int tmp = 0;
    while (x <= N && y <= N) {
      tmp += maze[x][y];
      x += 1, y += 1;
    }
    ans += (long long)tmp * (tmp - 1) / 2;
    tmp = 0;
    x = 1, y = i;
    while (x <= N && y >= 1) {
      tmp += maze[x][y];
      x += 1, y -= 1;
    }
    ans += (long long)tmp * (tmp - 1) / 2;
  }
  for (int i = 2; i <= N; i++) {
    int x = i, y = 1;
    int tmp = 0;
    while (x <= N && y <= N) {
      tmp += maze[x][y];
      x += 1, y += 1;
    }
    ans += (long long)tmp * (tmp - 1) / 2;
    tmp = 0;
    x = i, y = N;
    while (x <= N && y >= 1) {
      tmp += maze[x][y];
      x += 1, y -= 1;
    }
    ans += (long long)tmp * (tmp - 1) / 2;
  }
  cout << ans << endl;
}
