#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
struct ft {
  vector<ll> tree;
  void update(int i, ll val) {
    for (i++; i < (ll)(tree).size(); i += (i & (-i))) tree[i] += val;
  }
  ft(int n) { tree.assign(n + 1, 0); }
  ll prefix_sum(int i) {
    ll sum = 0;
    for (i++; i > 0; i -= (i & (-i))) sum += tree[i];
    return sum;
  }
};
ll count(vector<pair<ll, ll>> in) {
  vector<ll> speeds;
  for (auto& e : in) speeds.push_back(e.second);
  sort(begin(speeds), end(speeds));
  speeds.erase(unique(begin(speeds), end(speeds)), speeds.end());
  for (auto& e : in)
    e.second = distance(speeds.begin(),
                        lower_bound(begin(speeds), end(speeds), e.second));
  ll res = 0;
  ft count((ll)(speeds).size());
  ft pos((ll)(speeds).size());
  for (auto e : in) {
    res += count.prefix_sum(e.second) * e.first;
    res -= pos.prefix_sum(e.second);
    count.update(e.second, 1);
    pos.update(e.second, e.first);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<pair<ll, ll>> in(n);
  for (ll i = 0; i < n; i++) cin >> in[i].first;
  for (ll i = 0; i < n; i++) cin >> in[i].second;
  vector<pair<ll, ll>> ml, mr;
  for (ll i = 0; i < n; i++) {
    if (in[i].second <= 0) ml.push_back(in[i]);
    if (in[i].second >= 0) mr.push_back(in[i]);
  }
  sort(begin(ml), end(ml));
  sort(begin(mr), end(mr));
  ll res = 0;
  ll sum = 0;
  ll i = 0;
  for (auto e : mr) {
    while (i < (ll)(ml).size() && ml[i].first <= e.first) {
      sum += ml[i].first;
      i++;
    }
    res += i * e.first - sum;
  }
  res += count(ml);
  res += count(mr);
  cout << res << endl;
}
