#include <bits/stdc++.h>
using namespace std;
template <typename T>
T prod(const T &a, const T &b) {
  return ((a % ((long long int)1e9 + 7)) * (b % ((long long int)1e9 + 7))) %
         ((long long int)1e9 + 7);
}
template <typename T>
T pow_(const T &a, const T &b) {
  if (!b) return 1;
  long long int p = pow_(a, b / 2);
  p *= p;
  return (b % 2) ? (p * a) : p;
}
template <typename T>
T modpow(const T &a, const T &b) {
  if (!b) return 1;
  long long int p = modpow(a, b / 2);
  p = prod(p, p);
  return (b % 2) ? (prod(p, a)) : p;
}
template <typename T>
T gcd(const T &a, const T &b) {
  if (!b) return a;
  return gcd(b, a % b);
}
template <typename T>
T lcm(const T &a, const T &b) {
  return (a * b) / gcd(a, b);
}
template <typename T>
T max(const T &a, const T &b, const T &c) {
  return max(a, max(b, c));
}
template <typename T>
T min(const T &a, const T &b, const T &c) {
  return min(a, min(b, c));
}
template <typename T>
void dbg(const vector<T> &a, int l, int r) {
  for (int i = l; i <= r; i++) cout << a[i] << " ";
  cout << endl;
}
template <typename T>
void dbg(const vector<T> &a) {
  for (int i = 0; i <= a.size() - 1; i++) cout << a[i] << " ";
  cout << endl;
}
void main_() {
  int n;
  scanf("%d", &n);
  int mat[1000][1000];
  for (int i = 0; i <= 1000 - 1; i++)
    for (int j = 0; j <= 1000 - 1; j++) mat[i][j] = 0;
  for (int i = 0; i <= n - 1; i++) {
    int x, y;
    cin >> x >> y;
    mat[x - 1][y - 1] = 1;
  }
  long long int ans = 0;
  map<int, int> sum, diff;
  for (int i = 0; i <= 1000 - 1; i++)
    for (int j = 0; j <= 1000 - 1; j++)
      if (mat[i][j] == 0)
        continue;
      else {
        sum[i + j]++;
        diff[i - j]++;
      }
  for (auto it : sum) ans += 1LL * it.second * (it.second - 1) / 2;
  for (auto it : diff) ans += 1LL * it.second * (it.second - 1) / 2;
  cout << ans << endl;
}
int main() {
  { main_(); }
  return 0;
}
