#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const double eps = 1e-9;
bool was[1005][1005];
int main() {
  int n, x, y;
  long long ans = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> x >> y, was[x][y] = true;
  for (int t = 1000; t >= 1; --t) {
    int sum = 0;
    for (int j = 1, i = t; j <= 1001 - t, i <= 1000; ++j, ++i) {
      if (was[i][j]) sum++;
    }
    ans += ((sum) * (sum - 1)) / 2;
  }
  for (int t = 999; t >= 1; --t) {
    int sum = 0;
    for (int j = 1001 - t, i = 1; j <= 1000, i <= t; ++j, ++i) {
      if (was[i][j]) sum++;
    }
    ans += ((sum) * (sum - 1)) / 2;
  }
  for (int t = 1000; t >= 1; --t) {
    int sum = 0;
    for (int j = 1001 - t, i = 1; i <= 1001 - t, j >= 1; --j, ++i) {
      if (was[i][j]) sum++;
    }
    ans += ((sum) * (sum - 1)) / 2;
  }
  for (int t = 999; t >= 1; --t) {
    int sum = 0;
    for (int j = 1000, i = 1001 - t; i <= 1000, j >= 1001 - t; --j, ++i) {
      if (was[i][j]) sum++;
    }
    ans += ((sum) * (sum - 1)) / 2;
  }
  cout << ans;
  return 0;
}
