#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int a[1003][1003];
int main() {
  int n;
  long long int cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[x][y] = 1;
  }
  long long int p, q, fl;
  for (int i = 0; i <= 1000; i++) {
    p = 0;
    q = i;
    fl = 0;
    while (p <= 1000 and q <= 1000) {
      if (a[p][q]) fl++;
      p++;
      q++;
    }
    cnt += (fl * (fl - 1)) / 2;
    if (i) {
      p = i;
      q = 0;
      fl = 0;
      while (p <= 1000 and q <= 1000) {
        if (a[p][q]) fl++;
        p++;
        q++;
      }
      cnt += (fl * (fl - 1)) / 2;
    }
    p = 0;
    q = i;
    fl = 0;
    while (p <= 1000 and q >= 0) {
      if (a[p][q]) fl++;
      p++;
      q--;
    }
    cnt += (fl * (fl - 1)) / 2;
    if (i) {
      p = i;
      q = 1000;
      fl = 0;
      while (p <= 1000 and q >= 0) {
        if (a[p][q]) fl++;
        p++;
        q--;
      }
      cnt += (fl * (fl - 1)) / 2;
    }
  }
  cout << cnt << endl;
  return 0;
}
