#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int j = 0; j < n; j++) {
    cin >> b[j];
  }
  vector<int> diff(n);
  for (int i = 0; i < n; i++) {
    diff[i] = a[i] - b[i];
  }
  sort(diff.begin(), diff.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int ind = a[i] - b[i];
    ind *= -1;
    auto it = upper_bound(diff.begin(), diff.end(), ind);
    int temp = it - diff.begin();
    temp = n - temp;
    ans += temp;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      ans--;
    }
  }
  cout << ans / 2 << '\n';
  return 0;
}
