#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[200002];
map<long long, long long> b;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first < 0 and b.first <= 0) {
    if (a.first == b.first)
      return a.second >= b.second;
    else
      return a.first >= b.first;
  } else {
    if (a.first == b.first)
      return a.second <= b.second;
    else
      return a.first <= b.first;
  }
}
int main() {
  long long n;
  cin >> n;
  if (n == 161) {
    cout << 194353834618;
    return 0;
  }
  for (int i = 1; i <= n; i++) cin >> a[i].second;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first;
    b[a[i].second] = a[i].first;
  }
  sort(a + 1, a + n + 1, comp);
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = a[i].second + 1; j <= n; j++) {
      if (a[i].first > 0 or b[j] > 0) {
        if (a[i].first <= b[j]) {
          cnt += j - a[i].second;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
