#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
long long a[maxn], b[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    a[i] -= b[i];
  }
  sort(a, a + n, less<int>());
  int pos = 0;
  long long ans = 0;
  for (; pos < n; pos++) {
    if (a[pos] > 0) break;
    int c = upper_bound(a, a + n, -a[pos]) - a;
    ans = ans + (n - 1) - c + 1;
  }
  long long tep = (n - 1) - pos + 1;
  ans = ans + tep * (tep - 1) / 2;
  cout << ans;
  return 0;
}
