#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
const int N = 200000;
int n;
struct Node {
  int v, x;
  bool operator<(const Node& b) const { return x < b.x; }
} p[maxn];
struct BIT {
  int b[maxn];
  inline int lowbit(int x) { return x & (-x); }
  void update(int x, int v) {
    for (int i = x; i <= N; i += lowbit(i)) b[i] += v;
  }
  int query(int x) {
    int ans = 0;
    for (int i = x; i > 0; i -= lowbit(i)) ans += b[i];
    return ans;
  }
} a, b;
int tot[maxn], len[maxn];
int c[maxn], l[maxn];
map<int, int> mm;
int ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i].x;
  for (int i = 1; i <= n; i++) cin >> p[i].v, mm[p[i].v]++;
  int id = 0;
  for (map<int, int>::iterator it = mm.begin(); it != mm.end(); it++)
    it->second = ++id;
  for (int i = 1; i <= n; i++) p[i].v = mm[p[i].v];
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++) {
    ans += a.query(p[i].v) * p[i].x - b.query(p[i].v);
    a.update(p[i].v, 1);
    b.update(p[i].v, p[i].x);
  }
  cout << ans << endl;
  return 0;
}
