#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
bool p[maxn][maxn];
int n, m = 1000;
long long ans;
int C(int n, int m) { return n * (n - 1) / 2; }
int main() {
  int x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    p[x][y] = 1;
  }
  for (int s = 1; s <= m; s++) {
    x = 0;
    for (int i = s, j = 1; i <= m; i++, j++) x += p[i][j];
    ans += C(x, 2);
    x = 0;
    for (int i = s, j = 1; i >= 1; i--, j++) x += p[i][j];
    ans += C(x, 2);
  }
  for (int s = 2; s <= m; s++) {
    x = 0;
    for (int i = 1, j = s; j <= m; i++, j++) x += p[i][j];
    ans += C(x, 2);
    x = 0;
    for (int i = m, j = s; j <= m; i--, j++) x += p[i][j];
    ans += C(x, 2);
  }
  printf("%I64d", ans);
  return 0;
}
