#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long N = 1e7 + 10;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long powmod(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
long long readn() {
  long long sum = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + (ch - '0');
    ch = getchar();
  }
  return sum * f;
}
long long n, a[200005], b[200005];
long long x = 0, y = 0, ans = 0, c[200005];
long long first(long long x) {
  long long l = 1, r = n, mid, pp = -1;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (c[mid] >= x) {
      pp = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  return pp;
}
int main() {
  n = readn();
  for (long long i = 1; i <= n; i++) a[i] = readn();
  for (long long i = 1; i <= n; i++) b[i] = readn();
  for (long long i = 1; i <= n; i++) {
    c[i] = a[i] - b[i];
    if (c[i] > 0) x++;
    if (c[i] == 0) y++;
  }
  sort(c + 1, c + 1 + n);
  ans += (x) * (x - 1) / 2;
  ans += x * y;
  for (long long i = 1; i <= n; i++) {
    if (c[i] >= 0) break;
    long long op = first(c[i] * (-1) + 1);
    if (op != -1) ans += (n - op + 1);
  }
  cout << ans << endl;
}
