#include <bits/stdc++.h>
using namespace std;
template <typename T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <typename T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <typename T>
T med(T a, T b, T c) {
  return a + b + c - min(a, b, c) - max(a, b, c);
}
const int INF = 1e9;
const long long LINF = 1LL << 62;
struct pt {
  long long x, v;
};
bool cmp(pt A, pt B) { return A.x < B.x; }
const int MAXB = 20001;
const int BSIZE = 10000;
const int shift = 1e8;
int sbuckets[MAXB];
vector<pt> bbuckets[MAXB];
void insert(pt p) {
  long long vs = p.v + shift;
  sbuckets[vs / BSIZE] += p.x;
  bbuckets[vs / BSIZE].push_back(p);
}
long long get(pt p) {
  long long vs = p.v + shift;
  long long sm = 0;
  int amt = 0;
  for (int b = 0; (b + 1) * BSIZE < vs; b++) {
    sm += sbuckets[b];
    amt += bbuckets[b].size();
  }
  for (auto a : bbuckets[vs / BSIZE])
    if (p.v >= a.v) {
      sm += a.x;
      amt++;
    }
  return amt * p.x - sm;
}
int main() {
  int n;
  cin >> n;
  vector<pt> pts(n);
  for (int i = 0; i < n; i++) cin >> pts[i].x;
  for (int i = 0; i < n; i++) cin >> pts[i].v;
  sort(pts.begin(), pts.end(), cmp);
  long long res = 0;
  for (int cs = 0; cs < n; cs++) {
    res += get(pts[cs]);
    insert(pts[cs]);
  }
  cout << res << endl;
}
