#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> 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<long long> d(n);
  for (int i = 0; i < n; i++) d[i] = a[i] - b[i];
  sort(d.begin(), d.end());
  vector<long long> tmp;
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] > 0)
      tmp.push_back(d[i]);
    else if (d[i] == 0)
      cnt++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] >= 0) break;
    int idx = upper_bound(tmp.begin(), tmp.end(), abs(d[i])) - tmp.begin();
    ans += tmp.size() - idx;
  }
  ans += ((long long)tmp.size() * (long long)(tmp.size() - 1LL) / 2LL +
          (long long)tmp.size() * cnt);
  cout << ans << '\n';
  return 0;
}
