#include <bits/stdc++.h>
using namespace std;
struct point {
  double x, y;
  point(double _x = 0, double _y = 0) : x(_x), y(_y){};
};
double dist(point a, point b) {
  return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
}
bool cmp(point a, point b) { return a.x < b.x; }
struct line {
  double a, b, c;
  line(double _a = 1, double _b = 1, double _c = 1) : a(_a), b(_b), c(_c){};
};
line getline(point a, point b) {
  if (a.x == b.x)
    return (line(1.0, 0.0, -a.x));
  else
    return line(-(b.y - a.y) / (b.x - a.x), 1.0,
                (b.y - a.y) / (b.x - a.x) * a.x - a.y);
}
double getX(line l, double y) { return -(y * l.b + l.c) / l.a; }
int main() {
  int D1[1999] = {0};
  int D2[1999] = {0};
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    D1[a - 1 + b - 1]++;
    D2[a - 1 + 1000 - b]++;
  }
  long long int R = 0;
  for (int i = 0; i < 1999; i++) {
    if (D1[i] <= 1) continue;
    R += D1[i] * (D1[i] - 1) / 2;
  }
  for (int i = 0; i < 1999; i++) {
    if (D2[i] <= 1) continue;
    R += D2[i] * (D2[i] - 1) / 2;
  }
  cout << R << endl;
}
