#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long a[n], b[n], c[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) cin >> b[i];
  for (long long i = 0; i < n; i++) {
    c[i] = (a[i] - b[i]);
  }
  sort(c, c + n);
  long long answer = 0, answer1 = 0;
  for (long long i = 0; i < n; i++) {
    long long ans = a[i] - b[i];
    long long sum = 1 - ans;
    if (ans > 0) answer1++;
    long long ss = lower_bound(c, c + n, sum) - c;
    answer += (n - ss);
  }
  answer -= answer1;
  answer /= 2;
  cout << answer << endl;
  return 0;
}
