#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n;
  cin >> n;
  vector<long long int> a, d;
  for (long long int i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    a.push_back(temp);
  }
  for (long long int i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    d.push_back(a[i] - temp);
  }
  sort(d.begin(), d.end());
  long long int i = 0, j = n - 1, s = 0;
  while (i != j) {
    if (d[i] + d[j] > 0) {
      j--;
    } else {
      i++;
      s += n - j - 1;
    }
  }
  s += (n - j - 1) * (n - j) / 2;
  cout << s << endl;
  return 0;
}
