#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long a[n];
  long long b[n];
  long long c = 0;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) cin >> b[i];
  long long diff[n];
  for (long long i = 0; i < n; i++) {
    diff[i] = a[i] - b[i];
  }
  sort(diff, diff + n);
  long long firstnonneg = 0, firstpos = 0;
  while (firstnonneg < n && diff[firstnonneg] < 0) firstnonneg++;
  while (firstpos < n && diff[firstpos] <= 0) firstpos++;
  assert(firstnonneg <= firstpos);
  long long j = firstnonneg;
  long long ans = 0;
  for (long long i = firstpos; i < n; i++) {
    while (j >= 0 && diff[i] + diff[j] > 0) j--;
    ans += i - j - 1;
  }
  cout << ans << "\n";
  return 0;
}
