#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long a[200005], b[200005], c[200005];
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  for (long long i = 0; i < n; ++i) {
    scanf("%lld", &b[i]);
  }
  for (long long i = 0; i < n; ++i) {
    c[i] = a[i] - b[i];
  }
  sort(c, c + n);
  long long cnt = n - 1, ans = 0;
  for (long long i = 0; i < n - 1; ++i) {
    while (cnt > i && c[i] + c[cnt] > 0) {
      --cnt;
    }
    ans += min(n - 1 - cnt, n - 1 - i);
  }
  printf("%lld\n", ans);
  return 0;
}
