#include <bits/stdc++.h>
using namespace std;
class TaskD {
 public:
  void solve(std::istream &in, std::ostream &out) {
    long long n;
    in >> n;
    vector<long long> a(n), b(n), sa(n), sb(n);
    for (auto &i : a) in >> i;
    for (auto &i : b) in >> i;
    for (long long i = 0; i < n; ++i) {
      sa[i] = a[i] - b[i];
      sb[i] = b[i] - a[i];
    }
    sort((sa).begin(), (sa).end());
    sort((sb).begin(), (sb).end());
    long long ans = 0;
    for (long long i = 0; i < n; ++i) {
      ans += (long long)(sa.end() -
                         lower_bound((sa).begin(), (sa).end(), sb[i] + 1));
      if (sb[i] < 0) ans -= 1;
    }
    out << ans / 2 << endl;
  }
};
signed main() {
  TaskD solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
