#include <bits/stdc++.h>
using namespace std;
int N, k = 1;
vector<pair<long long, int>> v;
map<int, int> m;
long long fenwick[200050];
int f[200050];
void update(int pos, long long val) {
  for (; pos < 200050; pos += pos & -pos) fenwick[pos] += val;
}
void u(int pos, int v) {
  for (; pos < 200050; pos += pos & -pos) f[pos] += v;
}
int query(int pos) {
  long long res = 0;
  for (; pos > 0; pos -= pos & -pos) res += fenwick[pos];
  return res;
}
int q(int pos) {
  int res = 0;
  for (; pos > 0; pos -= pos & -pos) res += f[pos];
  return res;
}
int main() {
  cin >> N;
  v.resize(N);
  set<int> s;
  for (int i = 0; i < N; i++) scanf("%lld", &v[i].first);
  for (int i = 0; i < N; i++) {
    scanf("%d", &v[i].second);
    s.insert(v[i].second);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (auto x : s) m[x] = k++;
  for (int i = 0; i < N; i++) v[i].second = m[v[i].second];
  long long re = 0;
  for (auto x : v) update(x.second, x.first);
  for (auto x : v) u(x.second, 1);
  for (auto x : v) {
    re -= query(x.second) - x.first * (long long)q(x.second);
    update(x.second, -x.first);
    u(x.second, -1);
  }
  cout << re << "\n";
  return 0;
}
