#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return (b ? gcd(b, a % b) : a);
}
long long int fact_pow(long long int n, long long int k) {
  long long int res = 0;
  while (n) {
    n /= k;
    res += n;
  }
  return res;
}
long long int power(long long int x, unsigned long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
unsigned long long int factorial(unsigned long long int x) {
  if (x <= 1) return 1;
  return x * factorial(x - 1);
}
long long int nCr(unsigned long long int n, unsigned long long int r) {
  long long int p = 1, k = 1;
  if (n - r < r) r = n - r;
  if (r != 0) {
    while (r) {
      p *= n;
      k *= r;
      long long int m = gcd(p, k);
      p /= m;
      k /= m;
      n--;
      r--;
    }
  } else
    p = 1;
  return p;
}
vector<long long int> factors(long long int n) {
  vector<long long int> factorization;
  while (n % 2 == 0) {
    factorization.push_back(2);
    n /= 2;
  }
  for (long long int d = 3; d * d <= n; d += 2) {
    while (n % d == 0) {
      factorization.push_back(d);
      n /= d;
    }
  }
  if (n > 1) factorization.push_back(n);
  return factorization;
}
bool isPowerOfTwo(long long int n) {
  if (n == 0) return false;
  return (ceil(log2(n)) == floor(log2(n)));
}
void swap(long long int *x, long long int *y) {
  long long int t;
  t = *x;
  *x = *y;
  *y = t;
}
bool isSafe(long long int i, long long int j, long long int n,
            long long int m) {
  if (i < 0 || i >= n) return false;
  if (j < 0 || j >= m) return false;
  return true;
}
long long int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t, i, j, n, k, d, q, p, m;
  cin >> n;
  vector<long long int> a(n);
  vector<long long int> b(n);
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) cin >> b[i];
  long long int l, r;
  vector<long long int> c(n);
  for (i = 0; i < n; i++) c[i] = b[i] - a[i];
  long long int count = 0;
  sort(c.begin(), c.end());
  for (i = 0; i < n; i++) {
    auto itr = lower_bound(c.begin() + i + 1, c.end(), -c[i]);
    long long int add = itr - c.begin();
    count += (add - (i + 1));
  }
  cout << count << "\n";
  return 0;
}
