#include <bits/stdc++.h>
const double PI = 3.141592653589793238460;
using namespace std;
long long int FP(long long int arr[], long long int n, int x) {
  long long int l = 0, r = n - 1;
  long long int result = 0;
  while (l < r) {
    if (arr[l] + arr[r] > x) {
      result += (r - l);
      l++;
    } else
      r--;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int A[n], B[n];
  for (long long int i = 0; i < n; i++) cin >> A[i];
  for (long long int i = 0; i < n; i++) cin >> B[i];
  long long int s1 = 0, s2 = 0, count = 0;
  long long int C[n];
  for (long long int i = 0; i < n; i++) C[i] = A[i] - B[i];
  sort(C, C + n, greater<int>());
  count = FP(C, n, 0);
  cout << count << '\n';
}
