#include <bits/stdc++.h>
using namespace std;
bool A[1008][1008];
int main(int argc, char const *argv[]) {
  int n, x, y;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    A[x][y] = true;
  }
  long long ans = 0;
  int N = 1000;
  for (int j = 1; j <= N; j++) {
    int r = 1;
    int c = j;
    long long cnt = 0;
    while (r <= N && c <= N) {
      if (A[r][c] == true) cnt++;
      r++;
      c++;
    }
    ans += (cnt * (cnt - 1)) / 2;
  }
  for (int i = 2; i <= N; i++) {
    int r = i;
    int c = 1;
    long long cnt = 0;
    while (r <= N && c <= N) {
      if (A[r][c] == true) cnt++;
      r++;
      c++;
    }
    ans += (cnt * (cnt - 1)) / 2;
  }
  for (int j = 1; j <= N; j++) {
    int r = N;
    int c = j;
    long long cnt = 0;
    while (r >= 1 && c <= N) {
      if (A[r][c] == true) cnt++;
      r--;
      c++;
    }
    ans += (cnt * (cnt - 1)) / 2;
  }
  for (int i = N - 1; i >= 1; i--) {
    int r = i;
    int c = 1;
    long long cnt = 0;
    while (r >= 1 && c <= N) {
      if (A[r][c] == true) cnt++;
      r--;
      c++;
    }
    ans += (cnt * (cnt - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
