#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int a[n], b[n];
  vector<long long int> v, vp, vn;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) cin >> b[i];
  long long int po = 0, ze = 0, ne = 0;
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    v.push_back(a[i] - b[i]);
    if (v[i] > 0) {
      po++;
      vp.push_back(v[i]);
    }
    if (v[i] == 0) ze++;
    if (v[i] < 0) {
      ne++;
      vn.push_back(v[i]);
    }
  }
  if (vp.size() == 0) {
    cout << "0\n";
    return 0;
  }
  sort(vp.begin(), vp.end());
  for (long long int i = 0; i < vn.size(); i++) {
    long long int d = -(vn[i] - 1);
    if (d > vp[vp.size() - 1]) continue;
    long long int c = lower_bound(vp.begin(), vp.end(), d) - vp.begin();
    ans += vp.size() - c;
  }
  ans += ze * po;
  ans += (po * (po - 1)) / 2;
  cout << ans << "\n";
}
