#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n), b(n);
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = 0; i < n; i++) cin >> b[i];
    vector<long long> ba(n);
    for (long long i = 0; i < n; i++) ba[i] = b[i] - a[i];
    long long ans = 0;
    sort(ba.begin(), ba.end());
    for (long long i = 0; i < n; i++) {
      long long cnt =
          lower_bound(ba.begin(), ba.end(), a[i] - b[i]) - ba.begin();
      ans += cnt;
      if (a[i] > b[i]) ans--;
    }
    cout << ans / 2;
  }
}
