#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char c = getchar();
  long long f = 1, x = 0;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ '0');
    c = getchar();
  }
  return x * f;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long a[1000009], b[1000009], c[10000009];
int main() {
  long long n = read();
  long long i;
  for (i = 0; i < n; i++) {
    a[i] = read();
  }
  for (i = 0; i < n; i++) {
    b[i] = read();
    c[i] = a[i] - b[i];
  }
  sort(c, c + n);
  long long l = 0, r = n - 1, add = 0;
  while (1) {
    if (c[l] + c[r] > 0) {
      add += r - l;
      r--;
    } else {
      l++;
    }
    if (l == r) {
      break;
    }
  }
  printf("%lld\n", add);
  return 0;
}
