#include <bits/stdc++.h>
using namespace std;
int n, A[1002][1002];
long long sol = 0;
void stanga(int a, int b) {
  if (!(a < 1 || a > 1000 || b < 1 || b > 1000)) {
    if (A[a][b] == 1) sol++;
    stanga(a + 1, b - 1);
  }
}
void dreapta(int a, int b) {
  if (!(a < 1 || a > 1000 || b < 1 || b > 1000)) {
    if (A[a][b] == 1) sol++;
    dreapta(a + 1, b + 1);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    A[a][b] = 1;
  }
  for (int i = 1; i <= 1000; i++)
    for (int j = 1; j <= 1000; j++)
      if (A[i][j] == 1) {
        stanga(i + 1, j - 1);
        dreapta(i + 1, j + 1);
      }
  cout << sol;
  return 0;
}
