#include <bits/stdc++.h>
using namespace std;
const long long e = 5 * 1e5 + 7;
const long long mod = 1e9 + 7;
long long a[e], b[e];
long long s[e];
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    s[i] = a[i] - b[i];
  }
  sort(s, s + n);
  long long ans = 0;
  for (long long i = 0; i < n - 1; i++) {
    if (s[i] > 0) {
      ans += n - i - 1;
    } else if (s[i] == 0) {
      long long cur = lower_bound(s + i, s + n, s[i] + 1) - s;
      if (cur != n) {
        ans += n - cur;
      }
    } else {
      long long cur1 = lower_bound(s + i, s + n, abs(s[i]) + 1) - s;
      if (cur1 != n) {
        ans += n - cur1;
      }
    }
  }
  cout << ans;
}
