#include <bits/stdc++.h>
using namespace std;
const int mv4[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int mv8[8][2] = {{0, 1}, {0, -1}, {1, 0},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
const int inf = (int)1e9;
const char *boo[2] = {"NO", "YES"};
const char *inv = "Impossible";
inline void term(string msg = inv) {
  cout << msg << endl;
  exit(0);
}
const char *in = "in.txt";
const char *out = "out.txt";
struct Point {
  long long y, x;
  Point(long long y = 0, long long x = 0) : y(y), x(x) {}
  Point operator-(const Point &a) { return Point(y - a.y, x - a.x); }
};
inline unsigned long long sq(long long d) { return d * d; }
inline unsigned long long sqdist(const Point &a, const Point &b) {
  return sq(a.x - b.x) + sq(a.y - b.y);
}
inline long long dot(const Point &a, const Point &b) {
  return a.x * b.x + a.y * b.y;
}
const int MAX = 1000;
int main() {
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  int n;
  unsigned long long r = 0;
  cin >> n;
  vector<Point> v(n);
  unordered_map<int, int> dup, ddown;
  for (int i = 0; i < n; i++) {
    cin >> v[i].x >> v[i].y;
    dup[v[i].y - v[i].x]++;
    ddown[v[i].y + v[i].x]++;
  }
  for (auto e : dup) {
    unsigned long long t = (e.second * (e.second - 1)) / 2;
    r += t;
  }
  for (auto e : ddown) {
    unsigned long long t = (e.second * (e.second - 1)) / 2;
    r += t;
  }
  cout << r << '\n';
  exit(0);
}
