#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  long a[n], b[n];
  std::vector<long> v;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    v.push_back(a[i] - b[i]);
  }
  sort(v.begin(), v.end());
  long long count = 0;
  for (int i = 0; i < n - 1; i++) {
    long ser = 0 - v[i];
    count += n - (lower_bound(v.begin() + i + 1, v.end(), ser + 1) - v.begin());
  }
  cout << count;
  return 0;
}
