#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 1LL << 62;
const long long mx = 200005;
const double eps = 1e-10;
long long dx[10] = {1, 0, -1, 0};
long long dy[10] = {0, -1, 0, 1};
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long x = power(a, b / 2);
  x = x * x;
  if (b % 2) x = x * a;
  return x;
}
long long Set(long long N, long long pos) { return N = N | (1LL << pos); }
long long reset(long long N, long long pos) { return N = N & ~(1LL << pos); }
bool check(long long N, long long pos) { return (bool)(N & (1LL << pos)); }
pair<long long, long long> prr[mx];
long long arr[mx];
long long brr[mx];
unordered_map<long long, long long> mm;
unordered_map<long long, long long> nn;
long long tree[4 * mx];
long long tt[4 * mx];
void update(long long at, long long L, long long R, long long id,
            long long val) {
  if (R < id || L > id) return;
  if (L == R && id == R) {
    tree[at] += val;
    return;
  }
  long long mid = (L + R) / 2;
  update(2 * at, L, mid, id, val);
  update(2 * at + 1, mid + 1, R, id, val);
  tree[at] = tree[2 * at] + tree[2 * at + 1];
}
long long query(long long at, long long L, long long R, long long l,
                long long r) {
  if (l > R || r < L) return 0;
  if (l <= L && r >= R) return tree[at];
  long long mid = (L + R) / 2;
  long long a = query(2 * at, L, mid, l, r);
  long long b = query(2 * at + 1, mid + 1, R, l, r);
  return a + b;
}
void update2(long long at, long long L, long long R, long long id,
             long long val) {
  if (R < id || L > id) return;
  if (L == R && id == R) {
    tt[at] += val;
    return;
  }
  long long mid = (L + R) / 2;
  update2(2 * at, L, mid, id, val);
  update2(2 * at + 1, mid + 1, R, id, val);
  tt[at] = tt[2 * at] + tt[2 * at + 1];
}
long long query2(long long at, long long L, long long R, long long l,
                 long long r) {
  if (l > R || r < L) return 0;
  if (l <= L && r >= R) return tt[at];
  long long mid = (L + R) / 2;
  long long a = query2(2 * at, L, mid, l, r);
  long long b = query2(2 * at + 1, mid + 1, R, l, r);
  return a + b;
}
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first < b.first;
}
int main() {
  long long tst, a, b, c, k, n, m, res = 0, ans = 0, t = 0;
  set<long long> s;
  set<long long> ss;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
    s.insert(arr[i]);
  }
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &brr[i]);
    ss.insert(brr[i]);
  }
  for (auto i : s) {
    mm[i] = ++t;
  }
  t = 0;
  for (auto i : ss) {
    nn[i] = ++t;
  }
  for (long long i = 1; i <= n; i++) {
    a = arr[i], b = brr[i];
    a = mm[a], b = nn[b];
    prr[i] = {a, b};
  }
  sort(prr + 1, prr + 1 + n, comp);
  for (long long i = 1; i <= n; i++) {
    a = query(1, 1, n, 1, prr[i].second);
    b = query2(1, 1, n, 1, prr[i].second);
    res += (prr[i].first * a - b);
    update(1, 1, n, prr[i].second, 1);
    update2(1, 1, n, prr[i].second, prr[i].first);
  }
  printf("%lld\n", res);
  return 0;
}
