#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n], b[n], c[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long int i = 0; i < n; i++) {
    cin >> b[i];
    c[i] = a[i] - b[i];
  }
  sort(c, c + n);
  long long int k;
  for (long long int i = n - 1; i >= 0; i--) {
    if (c[i] <= 0) {
      k = i + 1;
      break;
    } else if (i == 0 && c[i] > 0) {
      cout << (n * (n - 1)) / 2;
      return 0;
    }
  }
  if (k == n) {
    cout << "0";
    return 0;
  }
  long long int t = k;
  long long int f = 0;
  for (long long int i = k; i < n; i++) {
    for (long long int j = t - 1; j >= 0; j--) {
      if (c[i] + c[j] <= 0) {
        t = j + 1;
        break;
      } else if (j == 0 && c[i] + c[j] > 0) {
        t = 0;
      }
    }
    f += (i - t);
  }
  cout << f;
  return 0;
}
