#include <bits/stdc++.h>
const int N = 3 * 1e5 + 5;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
using namespace std;
long long int modpow(long long int x, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
long long int modFact(long long int n, long long int p) {
  if (n >= p) return 0;
  long long int result = 1;
  for (long long int i = 1; i <= n; i++) result = (result * i) % p;
  return result;
}
bool isPrime(int x) {
  if (x % 2 == 0) return 0;
  for (int i = 3; i <= sqrt(x); i += 2) {
    if (x % i == 0) return 0;
  }
  return 1;
}
void solve() {
  int n;
  cin >> n;
  std::vector<std::pair<int, int> > pos;
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a;
    pos.push_back(make_pair(a, 0));
  }
  for (int i = 0; i < n; i++) {
    cin >> b;
    pos[i].second = b;
  }
  sort(pos.begin(), pos.end());
  std::vector<std::pair<int, int> > x, v;
  for (int i = 0; i < n; i++) {
    x.push_back(make_pair(pos[i].first, i));
    v.push_back(make_pair(pos[i].second, i));
  }
  sort(v.begin(), v.end());
  long long int dist = 0;
  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      dist += (1LL * 2 * i - n + 1) * x[i].first;
    }
  } else {
    for (int i = 0; i < n; i++) {
      dist += (1LL * 2 * i - n + 1) * x[i].first;
    }
  }
  for (int i = 0; i < n; i++) {
    dist += (i - v[i].second) * x[v[i].second].first;
  }
  cout << dist << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1, tt = 1;
  while (tt <= t) {
    solve();
    tt++;
  }
}
