#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t = 1;
  while (t--) {
    long long n, ans = 0, val = 0;
    cin >> n;
    vector<pair<long long, long long>> v(n);
    vector<long long> inko(n), ismese(n);
    for (long long i = 0; i < n; ++i) cin >> v[i].first;
    for (long long i = 0; i < n; ++i) cin >> v[i].second;
    sort(v.begin(), v.end());
    for (long long i = 0; i < n; ++i) {
      inko[i] = v[i].first - v[i].second, ismese[i] = -inko[i];
    }
    sort(ismese.begin(), ismese.end());
    for (long long i = 0; i < n; ++i) {
      val = lower_bound(ismese.begin(), ismese.end(), inko[i]) - ismese.begin();
      if (inko[i] > 0)
        ans += max(0LL, val - 1);
      else
        ans += val;
    }
    cout << ans / 2;
  }
}
