#include <bits/stdc++.h>
using namespace std;
struct BIT {
  vector<int> v;
  int n;
  BIT(int _n) : v(vector<int>(_n + 1, 0)), n(_n) {}
  int sum(int i) {
    int s = 0;
    while (i > 0) {
      s += v[i];
      i -= lsb(i);
    }
    return s;
  }
  int sum(int l, int r) { return sum(r) - sum(l - 1); }
  void add(int i, int x) {
    while (i <= n) {
      v[i] += x;
      i += lsb(i);
    }
  }

 private:
  int lsb(int i) { return i & -i; }
};
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  vector<int> x;
  for (int i = 0; i < n; i++) x.push_back(-a[i] + b[i]);
  sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  auto f = [&](int val) -> int {
    return lower_bound(x.begin(), x.end(), val) - x.begin();
  };
  int siz = x.size();
  BIT bit(siz);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int val = a[i] - b[i];
    ans += bit.sum(f(val));
    bit.add(f(-a[i] + b[i]) + 1, 1);
  }
  cout << ans << endl;
  return 0;
}
