#include <bits/stdc++.h>
using namespace std;
const double E = 2.718281828459;
const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 998244353;
const int maxn = 2e5 + 200;
const int maxm = 1e2;
int a[maxn], b[maxn];
int c[maxn * 2], mo[maxn * 2];
int n;
int number;
int zhaodao(int numberr) {
  return lower_bound(mo + 1, mo + number, numberr) - mo;
}
void addedge(int num) {
  while (num <= number) {
    c[num]++;
    num += num & (-num);
  }
}
long long chaxun(int x) {
  long long putssss = 0;
  while (x > 0) {
    putssss += c[x];
    x -= x & (-x);
  }
  return putssss;
}
int main() {
  long long putss = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  for (int j = 1; j <= n; ++j) scanf("%lld", &b[j]);
  for (int i = 1; i <= n; ++i) {
    mo[i] = b[i] - a[i];
  }
  for (int i = 1; i <= n; ++i) {
    mo[i + n] = a[i] - b[i];
  }
  sort(mo + 1, mo + 2 * n + 1);
  number = unique(mo + 1, mo + 2 * n + 1) - mo;
  int indexx = zhaodao(b[n] - a[n]);
  addedge(indexx);
  for (int i = n - 1; i; --i) {
    int xxx = zhaodao(a[i] - b[i]);
    putss += chaxun(xxx - 1);
    addedge(zhaodao(b[i] - a[i]));
  }
  cout << putss << endl;
  return 0;
}
