#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    long arr[n + 1], barr[n + 1];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> barr[i];
    }
    int cc[n + 1];
    for (int i = 0; i < n; i++) {
      cc[i] = arr[i] - barr[i];
    }
    sort(cc, cc + n);
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      int l = i + 1, h = n - 1;
      int val = -1;
      while (l <= h) {
        int mid = (l + h) / 2;
        if (cc[i] + cc[mid] > 0) {
          val = mid;
          h = mid - 1;
        } else {
          l = mid + 1;
        }
      }
      if (val != -1) {
        ans += n - val;
      }
    }
    cout << ans;
  }
  return 0;
}
