#include <bits/stdc++.h>
using namespace std;
const long long M = 1e7 + 10;
long long prime[M];
void precompute() {
  for (long long i = 2; i < M; i++) {
    if (!prime[i]) {
      for (long long j = 1; i * j < M; j++) prime[i * j] = i;
    }
  }
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a(n, 0);
  vector<long long> b(n, 0);
  vector<long long> v(n, 0);
  long long pos = 0, zero = 0;
  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++) {
    v[i] = a[i] - b[i];
    if (v[i] == 0)
      zero++;
    else if (v[i] > 0)
      pos++;
  }
  map<long long, long long> mp;
  for (long long i = 0; i < n; i++) mp[v[i]]++;
  auto i1 = mp.rbegin();
  auto i2 = mp.rbegin();
  i2++;
  while (i2 != mp.rend()) {
    i2->second += i1->second;
    i2++;
    i1++;
  }
  long long res = 0;
  long long r1 = (pos + zero) * (pos + zero - 1) / 2;
  long long r2 = (zero) * (zero - 1) / 2;
  if (pos + zero == 0) {
    cout << 0 << "\n";
    return 0;
  }
  auto kt = mp.begin();
  kt++;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    long long k = it->first;
    if (k >= 0) break;
    long long l = -k;
    auto jt = mp.upper_bound(l);
    if (jt == mp.end()) {
      kt++;
      continue;
    }
    if (kt != mp.end())
      res += jt->second * (it->second - kt->second);
    else
      res += jt->second * (it->second);
    kt++;
  }
  cout << res + r1 - r2 << "\n";
  return 0;
}
