#include <bits/stdc++.h>
using namespace std;
int a[1003][1003];
int main() {
  int n, x, y, i, j, k, dimX, dimY, ans, cnt;
  while (scanf("%d", &n) == 1) {
    memset(a, 0, sizeof(a));
    dimX = 1;
    dimY = 1;
    for (i = 0; i < n; i++) {
      scanf("%d %d", &x, &y);
      a[x][y] = 1;
      if (x > dimX) dimX = x;
      if (y > dimY) dimY = y;
    }
    ans = 0;
    for (k = 1; k <= dimY; k++) {
      cnt = 0;
      for (i = 1, j = k; i <= dimX && j <= dimY; i++, j++) {
        if (a[i][j]) {
          cnt++;
        }
      }
      ans += (cnt * (cnt - 1)) / 2;
    }
    for (k = 2; k <= dimX; k++) {
      cnt = 0;
      for (i = k, j = 1; i <= dimX && j <= dimY; i++, j++) {
        if (a[i][j]) {
          cnt++;
        }
      }
      ans += (cnt * (cnt - 1)) / 2;
    }
    for (k = 1; k <= dimX; k++) {
      cnt = 0;
      for (i = k, j = 1; i > 0 && j <= dimY; i--, j++) {
        if (a[i][j]) {
          cnt++;
        }
      }
      ans += (cnt * (cnt - 1)) / 2;
    }
    for (k = 2; k <= dimY; k++) {
      cnt = 0;
      for (i = dimX, j = k; i > 0 && j <= dimY; i--, j++) {
        if (a[i][j]) {
          cnt++;
        }
      }
      ans += (cnt * (cnt - 1)) / 2;
    }
    printf("%d\n", ans);
  }
  return 0;
}
