#include <bits/stdc++.h>
using namespace std;
inline long long int powmod(long long int base, long long int exponent,
                            long long int mod = (1e9 + 7)) {
  long long int ans = 1;
  while (exponent) {
    if (exponent & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    exponent /= 2;
  }
  return ans;
}
inline vector<int> Siv(int n) {
  int i, p;
  vector<bool> prime;
  vector<int> pr;
  for (i = 0; i <= n; i++) prime.push_back(true);
  for (p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      cout << p << " ";
      pr.push_back(p);
      for (i = p * p; i <= n; i += p) {
        prime[i] = false;
      }
    }
  }
  for (i = p; i <= n; i++) {
    if (prime[i] == true) {
      cout << i << " ";
      pr.push_back(i);
    }
  }
  return pr;
}
inline int factors(int n, vector<int> pr, int* pt, int max1) {
  int count = 0, tot = 0, temp = n, num = 0, flag;
  for (int x = 0; x < pr.size(); x++) {
    count = 0, flag = 0;
    while (temp % pr[x] == 0) {
      count++;
      temp = temp / pr[x];
      flag = 1;
    }
    tot = tot + count;
    if (temp == 1) break;
  }
  if (temp != 1) return tot + 1;
  return tot;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t, n1, n2, n3, max1 = 0, max2 = 0, lsb, a, b, i, temp, j, sum,
                               tot, prod, count = 0, ans = 1, flag;
  long long int mod = 1000000007;
  unordered_multiset<string> us1, us2;
  string stemp = "}}";
  vector<int> v;
  cin >> t;
  for (i = 0; i < t; ++i) {
    cin >> a;
    v.push_back(a);
  }
  for (i = 0; i < t; ++i) {
    cin >> a;
    v[i] -= a;
  }
  count = 0;
  sort(v.begin(), v.end());
  for (i = 0; i < t; ++i) {
    if (v[i] <= 0) {
      v[i] = abs(v[i]);
      a = v.end() - lower_bound(v.begin() + i, v.end(), v[i] + 1);
      count += a;
    } else
      break;
  }
  if (i < t) {
    a = t - i - 1;
    count += (a * (a + 1)) / 2;
  }
  cout << count;
}
