#include <bits/stdc++.h>
using namespace std;
const int maxN = 200000 + 5;
int a[maxN], b[maxN], c[maxN * 2], d[maxN];
int n, sz;
long long ans;
vector<int> vec;
void discrete() {
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for (int i = 1; i <= n; ++i)
    d[i] = lower_bound(vec.begin(), vec.end(), d[i]) - vec.begin() + 1;
  sz = vec.size();
}
void add(int x, int val) {
  for (; x <= sz; x += x & (-x)) c[x] += val;
}
int sum(int x) {
  int res = 0;
  for (; x; x -= x & (-x)) res += c[x];
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &b[i]);
    d[i] = b[i] - a[i];
    vec.push_back(d[i]);
    vec.push_back(a[i] - b[i]);
  }
  discrete();
  for (int i = n; i >= 2; --i) {
    add(d[i], 1);
    int val =
        lower_bound(vec.begin(), vec.end(), a[i - 1] - b[i - 1]) - vec.begin();
    ans += sum(val);
  }
  printf("%lld\n", ans);
  return 0;
}
