#include <bits/stdc++.h>
const int inf = 1e9 + 7;
const int md = 1e9 + 7;
const double eps = -1e5;
using namespace std;
int n, ans, x, y;
bool a[1001][1001];
bool isin(int x, int y) { return x > 0 && x <= 1000 && y > 0 && y <= 1000; }
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    a[x][y] = true;
  }
  for (int x = 1; x <= 1000; x++)
    for (int y = 1; y <= 1000; y++)
      if (a[x][y]) {
        for (int xx = x, yy = y; isin(xx, yy); xx--, yy--) ans += a[xx][yy];
        ans--;
        for (int xx = x, yy = y; isin(xx, yy); xx++, yy--) ans += a[xx][yy];
        ans--;
        for (int xx = x, yy = y; isin(xx, yy); xx--, yy++) ans += a[xx][yy];
        ans--;
        for (int xx = x, yy = y; isin(xx, yy); xx++, yy++) ans += a[xx][yy];
        ans--;
      }
  cout << ans / 2;
}
