#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long long mod = 14062008;
int CASE = 1;
const int mxn = 1e5 + 1;
const long long infll = 1e18;
const int infi = 1e9;
bool prime(long long n) {
  if (n <= 1) return false;
  if (n == 2 or n == 3) return true;
  if (n % 2 == 0 or n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i += 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long __gcd(long long a, long long b) { return !b ? a : __gcd(b, a % b); }
long long power(long long a, long long b, long long MOD) {
  long long x = a, res = 1, p = b;
  while (p > 0) {
    if (p & 1) res *= x;
    x *= x;
    p >>= 1;
    x %= MOD, res %= MOD;
  }
  return res;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) cin >> b[i];
  vector<int> x, y;
  for (long long i = 0; i < n; i++) {
    x.push_back(a[i] - b[i]);
    y.push_back(b[i] - a[i]);
  }
  vector<int> v = y;
  sort(v.begin(), v.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    auto ite = lower_bound(v.begin(), v.end(), y[i]);
    v.erase(ite, ite + 1);
    auto it = lower_bound(v.begin(), v.end(), x[i]);
    ans += it - v.begin();
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
