#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b, long long int m) {
  long long int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int a[n + 2], b[n + 2], c[n + 2];
  for (long long int i = 1; i < n + 1; i++) cin >> a[i];
  for (long long int i = 1; i < n + 1; i++) cin >> b[i];
  vector<long long int> v;
  for (long long int i = 1; i < n + 1; i++) v.push_back(b[i] - a[i]);
  sort((v).begin(), (v).end());
  long long int ans = 0;
  for (long long int i = 1; i < n + 1; i++) {
    long long int haha = a[i] - b[i];
    auto it = lower_bound((v).begin(), (v).end(), haha);
    long long int ind = it - v.begin();
    if (b[i] - a[i] < haha) ind--;
    ans += max(ind, 0LL);
  }
  cout << ans / 2 << endl;
}
