#include <bits/stdc++.h>
using namespace std;
long long int n, a[200007], b[200007], res;
vector<long long int> diff;
int main() {
  scanf("%lld", &n);
  for (long long int i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for (long long int i = 0; i < n; ++i) scanf("%lld", &b[i]);
  for (long long int i = 0; i < n; ++i) diff.push_back(a[i] - b[i]);
  sort(diff.begin(), diff.end());
  for (long long int i = 0; i < n; ++i) {
    long long int low =
        lower_bound(diff.begin(), diff.end(), -1 * (diff[i]) + 1) -
        diff.begin();
    if (low < i) res += i - low;
  }
  printf("%lld\n", res);
  return 0;
}
