#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int* a = new int[n];
  int* b = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int* c = new int[n];
  for (int i = 0; i < n; i++) {
    c[i] = b[i] - a[i];
  }
  sort(c, c + n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    auto it = lower_bound(c + i + 1, c + n, -c[i]);
    long long id = it - c;
    ans += id - (i + 1);
  }
  cout << ans << endl;
  return 0;
}
