#include <bits/stdc++.h>
using namespace std;
int a[200008], b[200008], arr[200008];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, res = 0, t;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    arr[i] = a[i] - b[i];
  }
  sort(arr + 1, arr + n + 1);
  for (int i = 1; i <= n; i++) {
    t = b[i] - a[i];
    t = upper_bound(arr + 1, arr + n + 1, t) - arr;
    res += n - t + 1;
    if (a[i] - b[i] > 0) res--;
  }
  cout << res / 2;
  return 0;
}
