#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  long long int a[n], b[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) a[i] = a[i] - b[i];
  sort(a, a + n);
  int start = n - 1;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    while (start >= 0 && a[i] + a[start] > 0) start--;
    ans += (n - 1 - start);
  }
  for (int i = 0; i < n; i++) {
    if (a[i] > 0) ans--;
  }
  ans = ans >> 1;
  cout << ans << "\n";
  return 0;
}
