#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> A(n), B(n), C(n);
  for (auto& a : A) cin >> a;
  int i = 0;
  for (auto& b : B) {
    cin >> b;
    C[i] = A[i] - b;
    i++;
  }
  sort(C.begin(), C.end());
  long long ans = 0;
  int l = 0, r = n - 1;
  while (r > l) {
    if (C[l] + C[r] <= 0) {
      l++;
      continue;
    }
    ans += r - l;
    r--;
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  while (T--) solve();
  return 0;
}
