#include <bits/stdc++.h>
template <typename T, typename U>
std::istream& operator>>(std::istream& input, std::pair<T, U>& v) {
  return input >> v.first >> v.second;
}
template <typename T>
std::istream& operator>>(std::istream& input, std::vector<T>& v) {
  for (T& a : v) input >> a;
  return input;
}
using integer = unsigned long long;
void answer(integer v) { std::cout << v << '\n'; }
void solve(const std::vector<std::pair<unsigned, unsigned>>& p) {
  integer c[2][2000] = {}, k = 0;
  for (const auto& q : p) {
    k += c[0][q.first + q.second - 1]++;
    k += c[1][999 + q.first - q.second]++;
  }
  answer(k);
}
int main() {
  size_t n;
  std::cin >> n;
  std::vector<std::pair<unsigned, unsigned>> p(n);
  std::cin >> p;
  solve(p);
  return 0;
}
