#include <bits/stdc++.h>
using namespace std;
long long bit[4][200005];
void update(long long k, long long val, long long p) {
  while (k < 200005) {
    bit[p][k] += val;
    k += (k & (-k));
  }
}
long long query(long long k, long long p) {
  long long s = 0;
  while (k > 0) {
    s += bit[p][k];
    k -= (k & (-k));
  }
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  pair<long long, long long> p[n];
  set<long long> v1, v2;
  for (int i = 0; i < n; i++) cin >> p[i].first;
  for (int i = 0; i < n; i++) {
    cin >> p[i].second;
    if (p[i].second < 0)
      v1.insert(abs(p[i].second));
    else if (p[i].second > 0)
      v2.insert(p[i].second);
  }
  map<long long, long long> mp, mp2;
  int cnt = 1;
  for (auto i : v1) mp[-i] = cnt, cnt++;
  cnt = 1;
  for (auto i : v2) mp2[i] = cnt, cnt++;
  sort(p, p + n);
  long long ans = 0;
  long long stat = 0, cn = 0;
  for (int i = 0; i < n; i++) {
    if (p[i].second > 0) {
      p[i].second = mp2[p[i].second];
      long long sum = query(p[i].second, 1) + query(200000, 0);
      long long num = query(p[i].second, 3) + query(200000, 2);
      ans += num * p[i].first - sum;
      update(p[i].second, p[i].first, 1);
      update(p[i].second, 1, 3);
    } else if (p[i].second < 0) {
      p[i].second = mp[p[i].second];
      long long sum = query(200000, 0) - query(p[i].second - 1, 0);
      long long num = query(200000, 2) - query(p[i].second - 1, 2);
      ans += num * p[i].first - sum;
      update(p[i].second, p[i].first, 0);
      update(p[i].second, 1, 2);
    } else {
      long long sum = stat + query(200000, 0);
      long long num = cn + query(200000, 2);
      ans += num * p[i].first - sum;
      stat += p[i].first;
      cn++;
    }
  }
  cout << ans;
}
