#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int n;
long long a[MAXN], b[MAXN];
long long aa[MAXN], bb[MAXN];
struct Segment {
  vector<int> tree;
  int size;
  Segment() {}
  Segment(int N) : size(N) { tree.resize(4 * N, 0); }
  int init(int node, int nl, int nr) {
    if (nl == nr) return tree[node] = 1;
    int mid = (nl + nr) >> 1;
    return tree[node] =
               init(node * 2, nl, mid) + init(node * 2 + 1, mid + 1, nr);
  }
  void init() { init(1, 0, size - 1); }
  int update(int idx, int val, int node, int nl, int nr) {
    if (nl > idx || nr < idx) return tree[node];
    if (nl == nr) return tree[node] += val;
    int mid = (nl + nr) >> 1;
    return tree[node] = update(idx, val, node * 2, nl, mid) +
                        update(idx, val, node * 2 + 1, mid + 1, nr);
  }
  void update(int idx, int val) { update(idx, val, 1, 0, size - 1); }
  int query(int l, int r, int nl, int nr, int node) {
    if (r < nl || l > nr) return 0;
    if (l <= nl && nr <= r) return tree[node];
    int mid = (nl + nr) >> 1;
    return query(l, r, nl, mid, node * 2) +
           query(l, r, mid + 1, nr, node * 2 + 1);
  }
  int query(int l, int r) { return query(l, r, 0, size - 1, 1); }
};
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  for (int i = 0; i < n; i++) scanf("%lld", &b[i]);
  vector<int> v;
  for (int i = 0; i < n; i++) {
    aa[i] = a[i] - b[i];
    bb[i] = -a[i] + b[i];
    v.push_back(bb[i]);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  Segment seg(v.size() + 2);
  for (int i = 0; i < n; i++) {
    int idx = lower_bound(v.begin(), v.end(), bb[i]) - v.begin();
    seg.update(idx, 1);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int idx = lower_bound(v.begin(), v.end(), bb[i]) - v.begin();
    seg.update(idx, -1);
    idx = lower_bound(v.begin(), v.end(), aa[i]) - v.begin();
    int p = n - i - seg.query(idx, v.size() + 2) - 1;
    ans += p;
  }
  printf("%lld\n", ans);
  return 0;
}
