#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int n;
long long vv[maxn];
long long num1[maxn], num2[maxn];
struct xiao {
  long long x, v;
} a[maxn];
long long lowbit(long long x) { return x & (-x); }
void updata(long long i, long long k, long long num[]) {
  while (i < n) {
    num[i] += k;
    i += lowbit(i);
  }
}
long long query(long long i, long long num[]) {
  long long ans = 0;
  while (i) {
    ans += num[i];
    i -= lowbit(i);
  }
  return ans;
}
bool cmp(xiao a, xiao b) { return a.x == b.x ? a.v < b.v : a.x < b.x; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i].x);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i].v);
    vv[i] = a[i].v;
  }
  sort(a + 1, a + 1 + n, cmp);
  sort(vv + 1, vv + 1 + n);
  long long putss = 0;
  for (int i = 1; i <= n; ++i) {
    int pt = lower_bound(vv + 1, vv + 1 + n, a[i].v) - vv;
    putss += query(pt, num1) * a[i].x - query(pt, num2);
    updata(pt, 1, num1);
    updata(pt, a[i].x, num2);
  }
  cout << putss << endl;
  return 0;
}
