#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int T[N], S[N], C[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> T[i];
  for (int i = 0; i < n; i++) cin >> S[i];
  for (int i = 0; i < n; i++) C[i] = T[i] - S[i];
  sort(C, C + n);
  long long l = 0, r = n - 1, res = 0;
  while (l < r) {
    if (C[l] + C[r] > 0) {
      res += (r - l);
      r--;
    } else
      l++;
  }
  cout << res << endl;
}
