#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int b[n];
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  long long int amb[n];
  vector<long long int> bma(n);
  for (int i = 0; i < n; i++) {
    amb[i] = a[i] - b[i];
    bma[i] = -amb[i];
  }
  sort(bma.begin(), bma.end());
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    long long int x = amb[i];
    if (x > 0) {
      sum += (lower_bound(bma.begin(), bma.end(), amb[i]) - bma.begin());
      sum--;
    } else {
      sum += (lower_bound(bma.begin(), bma.end(), amb[i]) - bma.begin());
    }
  }
  cout << sum / 2 << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
