#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int n;
  cin >> n;
  long long int *a = new long long int[n];
  long long int *b = new long long int[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];
  long long int *c = new long long int[n];
  long long int d = 0;
  for (long long int i = 0; i < n; i++) {
    c[i] = b[i] - a[i];
    if (c[i] == 0) d++;
  }
  if (d == n) {
    cout << "0";
  } else {
    sort(c, c + n);
    long long int ans = 0;
    for (long long int i = 0; i < n; i++) {
      auto it = lower_bound(c + i + 1, c + n, -c[i]);
      long long int id = it - c;
      ans = ans + (id - (i + 1));
    }
    cout << ans << "\n";
  }
  return 0;
}
