#include <bits/stdc++.h>
#pragma GCC fast("Ofast")
using namespace std;
const long long N = 1e6;
signed main() {
  long long int t = 1;
  while (t-- > 0) {
    long long int n, k;
    cin >> n;
    vector<long long int> v(n);
    for (auto i = 0; i < n; i++) {
      cin >> v[i];
    }
    for (auto i = 0; i < n; i++) {
      long long int a;
      cin >> a;
      v[i] -= a;
    }
    sort(v.begin(), v.end());
    long long int le = 0, ri = n - 1, cnt = 0;
    while (le < ri) {
      if (v[le] + v[ri] > 0) {
        cnt += ri - le, --ri;
      } else {
        ++le;
      }
    }
    cout << cnt << '\n';
  }
}
