#include <bits/stdc++.h>
using namespace std;
int GetIdx1(int x, int y) { return x - y; }
int GetIdx2(int x, int y) {
  x = 1000 - x - 1;
  return x - y;
}
int64_t Calc(const map<int, int>& m) {
  int64_t result = 0;
  for (const auto& p : m) {
    result += 1LL * p.second * (p.second - 1) / 2;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<pair<int, int>> pts(N);
  map<int, int> A, B;
  for (auto& p : pts) {
    cin >> p.first >> p.second;
    --p.first;
    --p.second;
    A[GetIdx1(p.first, p.second)]++;
    B[GetIdx2(p.first, p.second)]++;
  }
  int64_t result = Calc(A) + Calc(B);
  cout << result << '\n';
  return 0;
}
