#include <bits/stdc++.h>
using namespace std;
class FenwickTree {
  long long n;
  vector<int> BIT;

 public:
  FenwickTree(long long n) {
    this->n = n;
    BIT.assign(n + 1, 0);
  }
  void update(long long x, long long v) {
    while (x <= n) {
      BIT[x] += v;
      x += (x & -x);
    }
  }
  long long query(long long x) {
    long long s = 0;
    while (x > 0) {
      s += BIT[x];
      x -= (x & -x);
    }
    return s;
  }
};
class TaskF {
  long long n, res;
  vector<pair<long long, long long>> a;
  vector<long long> x, v;
  map<long long, long long> m;

 public:
  TaskF(long long n) {
    this->n = n;
    res = 0;
    a.assign((n + 1), {LONG_MIN, LONG_MIN});
    for (long long i = 1; i <= n; i++) {
      cin >> a[i].first;
    }
    for (long long i = 1; i <= n; i++) {
      cin >> a[i].second;
    }
  }
  long long get() {
    sort(a.begin(), a.end());
    for (int i = 1; i <= n; i++) {
      x.emplace_back(a[i].first);
      v.emplace_back(a[i].second);
      m[a[i].second];
    }
    int k = 0;
    for (auto &it : m) {
      it.second = (++k);
    }
    for (auto &it : v) {
      it = m[it];
    }
    FenwickTree F1(k), F2(k);
    for (long long i = 0; i < n; i++) {
      long long c = F1.query(v[i]);
      long long s = F2.query(v[i]);
      res += (c * x[i]) - s;
      F1.update(v[i], 1);
      F2.update(v[i], x[i]);
    }
    return res;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  TaskF T(n);
  cout << T.get() << '\n';
}
