#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int mod = 1000000007;
const long double DOUBLE_MAX = DBL_MAX;
inline bool vowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y')
    return true;
  return false;
}
char toLower(char c) {
  if (c - 'a' < 0) {
    return (char)(c + 'a' - 'A');
  }
  return c;
}
int main(int argc, char* argv[]) {
  std::ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  long long int x[n], y[n];
  for (int i = (0); i < (n); i++) cin >> x[i];
  for (int i = (0); i < (n); i++) cin >> y[i];
  long long int arr[n];
  for (int i = (0); i < (n); i++) {
    arr[i] = x[i] - y[i];
  }
  sort(arr, arr + n);
  long long int ans = 0;
  for (int i = (0); i < (n); i++) {
    if (arr[i] < 0) {
      long long int target = -1 * arr[i] + 1;
      long long int start = lower_bound(arr, arr + n, target) - arr;
      if (start < n) {
        ans += n - start;
      }
    } else if (arr[i] == 0) {
      long long int target = 1;
      long long int start = lower_bound(arr, arr + n, target) - arr;
      if (start < n) {
        ans += n - start;
      }
    } else {
      long long int target = -1 * arr[i] + 1;
      long long int start = lower_bound(arr, arr + n, target) - arr;
      if (start < n) {
        ans += n - start;
      }
      ans--;
    }
  }
  ans = ans / 2;
  cout << ans << endl;
  return 0;
}
