#include <bits/stdc++.h>
using namespace std;
int n, x, y, col[1002][1002];
int main() {
  long long ans;
  memset(col, 0, sizeof(col));
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    col[x][y] = 1;
  }
  ans = 0;
  for (int i = 1; i <= 1000; i++) {
    for (int j = 1; j <= 1000; j++) {
      if (col[i][j] == 1) {
        long long len = 0;
        for (int k = i, l = j; k > 0 && l > 0; k--, l--) {
          if (col[k][l] == 1) {
            len++;
            col[k][l] = 2;
          }
        }
        for (int k = i, l = j; k <= 1000 && l <= 1000; k++, l++) {
          if (col[k][l] == 1) {
            len++;
            col[k][l] = 2;
          }
        }
        if (len > 1) ans += (len * (len - 1)) / 2;
      }
    }
  }
  for (int i = 1; i <= 1000; i++) {
    for (int j = 1; j <= 1000; j++) {
      if (col[i][j] == 2) {
        int len = 0;
        for (int k = i, l = j; k > 0 && l <= 1000; k--, l++) {
          if (col[k][l] == 2) {
            len++;
            col[k][l] = 3;
          }
        }
        for (int k = i, l = j; k <= 1000 && l > 0; k++, l--) {
          if (col[k][l] == 2) {
            len++;
            col[k][l] = 3;
          }
        }
        if (len > 1) ans += (len * (len - 1)) / 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
