#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const unsigned long long mx = 1333333331;
inline void RI(int &x) {
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0';
}
int num1[500005];
int num2[500005];
int main() {
  int n;
  while (cin >> n) {
    memset(num1, 0, sizeof(num1));
    memset(num2, 0, sizeof(num2));
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      ans += (long long)num1[x - y + n];
      ans += (long long)num2[x + y];
      num1[x - y + n]++;
      num2[x + y]++;
    }
    cout << ans << endl;
  }
  return 0;
}
