#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; ++i) cin >> a[i];
  long long int b[n];
  for (long long int i = 0; i < n; ++i) cin >> b[i];
  long long int neg = 0, zero = 0;
  vector<long long int> pos, nega;
  for (long long int i = 0; i < n; ++i) {
    if (a[i] == b[i])
      zero++;
    else {
      if (a[i] < b[i]) {
        neg++;
        nega.push_back(a[i] - b[i]);
      } else {
        pos.push_back(a[i] - b[i]);
      }
    }
  }
  long long int st = zero * neg;
  if (zero) st += ((zero * (zero - 1)) / 2);
  if (neg) st += ((neg * (neg - 1)) / 2);
  sort(pos.begin(), pos.end());
  sort(nega.begin(), nega.end(), greater<long long int>());
  long long int pre = 0;
  for (long long int i = 0; i < nega.size(); ++i) {
    long long int j;
    for (j = pre; j < pos.size(); ++j) {
      if (nega[i] + pos[j] <= 0) {
        st += (nega.size() - i);
      } else {
        pre = j;
        break;
      }
    }
    if (j == pos.size()) break;
  }
  long long int tot = (n * (n - 1)) / 2;
  cout << max(tot - st, 0LL);
}
