#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n;
  cin >> n;
  long long int a[n];
  long long int b[n];
  for (long long int i = 0; i < n; ++i) cin >> a[i];
  for (long long int i = 0; i < n; ++i) cin >> b[i];
  long long int ans = 0;
  long long int abi[n], baj[n + 1], m[n];
  for (long long int i = 0; i < n; ++i) {
    abi[i] = a[i] - b[i];
  }
  for (long long int i = 0; i < n; ++i) {
    baj[i] = b[i] - a[i];
  }
  baj[n] = 1e9 + 7;
  sort(baj, baj + n + 1);
  for (long long int i = 0; i < n; ++i) {
    long long int k = lower_bound(baj, baj + n + 1, abi[i]) - baj;
    if (a[i] > b[i]) --k;
    ans += k;
  }
  cout << ans / 2;
}
