#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (!y) return x;
  return gcd(y, x % y);
}
const long long MOD = 1e9 + 7;
int inf = 1e9 + 7;
long long INF = 2e18 + 9;
long long power(long long x, long long y) {
  long long res = 1ll;
  x %= MOD;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % MOD;
    y = y >> 1ll;
    x = (x * x) % MOD;
  }
  return res;
}
long long inv(long long x) {
  long long r = 1ll, t = x, k = MOD - 2ll;
  while (k) {
    if (k & 1ll) r = (long long)r * t % MOD;
    t = (long long)t * t % MOD;
    k >>= 1;
  }
  return r;
}
bool isPrime(long long x) {
  if (x == 1) return false;
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
const int nax = 5e5 + 13;
void prep() {}
void solve() {}
vector<long long> fenwick[2];
int n;
void add(int pos, long long val, int ind) {
  pos++;
  while (pos <= n) {
    fenwick[ind][pos] += val;
    pos += pos & (-pos);
  }
}
long long query(int pos, int ind) {
  long long res = 0;
  pos++;
  while (pos) {
    res += fenwick[ind][pos];
    pos -= pos & (-pos);
  }
  return res;
}
void read() {
  cin >> n;
  vector<pair<int, int> > xv(n);
  for (int i = 0; i < n; i++) {
    cin >> xv[i].first;
  }
  for (int i = 0; i < n; i++) {
    cin >> xv[i].second;
  }
  vector<int> tmp;
  for (int i = 0; i < n; i++) tmp.push_back(xv[i].second);
  sort(tmp.begin(), tmp.end());
  auto it = unique(tmp.begin(), tmp.end());
  tmp.resize(distance(tmp.begin(), it));
  map<int, int> M;
  for (int i = 0; i < tmp.size(); i++) {
    M[tmp[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    xv[i].second = M[xv[i].second];
  }
  sort(xv.begin(), xv.end());
  int N = n;
  n = tmp.size();
  fenwick[0].resize(n + 1);
  fenwick[1].resize(n + 1);
  for (auto& el : fenwick[0]) el = 0;
  for (auto& el : fenwick[1]) el = 0;
  long long res = 0;
  for (int i = 0; i < N; i++) {
    res += xv[i].first * query(xv[i].second, 0) - query(xv[i].second, 1);
    add(xv[i].second, 1, 0);
    add(xv[i].second, xv[i].first, 1);
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  srand(time(NULL));
  int T = 1;
  prep();
  for (int i = 1; i <= T; i++) {
    read();
    solve();
  }
  return 0;
}

### Prompt

In Cpp, your task is to solve the following problem:

There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ⋅ v_i.

Consider two points i and j. Let d(i, j) be the minimum possible distance between these two points over any possible moments of time (even non-integer). It means that if two points i and j coincide at some moment, the value d(i, j) will be 0.

Your task is to calculate the value ∑_{1 ≤ i < j ≤ n} d(i, j) (the sum of minimum distances over all pairs of points).

Input

The first line of the input contains one integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of points.

The second line of the input contains n integers x_1, x_2, ..., x_n (1 ≤ x_i ≤ 10^8), where x_i is the initial coordinate of the i-th point. It is guaranteed that all x_i are distinct.

The third line of the input contains n integers v_1, v_2, ..., v_n (-10^8 ≤ v_i ≤ 10^8), where v_i is the speed of the i-th point.

Output

Print one integer — the value ∑_{1 ≤ i < j ≤ n} d(i, j) (the sum of minimum distances over all pairs of points).

Examples

Input


3
1 3 2
-100 2 3


Output


3


Input


5
2 1 4 3 5
2 2 2 3 4


Output


19


Input


2
2 1
-3 0


Output


0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (!y) return x;
  return gcd(y, x % y);
}
const long long MOD = 1e9 + 7;
int inf = 1e9 + 7;
long long INF = 2e18 + 9;
long long power(long long x, long long y) {
  long long res = 1ll;
  x %= MOD;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % MOD;
    y = y >> 1ll;
    x = (x * x) % MOD;
  }
  return res;
}
long long inv(long long x) {
  long long r = 1ll, t = x, k = MOD - 2ll;
  while (k) {
    if (k & 1ll) r = (long long)r * t % MOD;
    t = (long long)t * t % MOD;
    k >>= 1;
  }
  return r;
}
bool isPrime(long long x) {
  if (x == 1) return false;
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
const int nax = 5e5 + 13;
void prep() {}
void solve() {}
vector<long long> fenwick[2];
int n;
void add(int pos, long long val, int ind) {
  pos++;
  while (pos <= n) {
    fenwick[ind][pos] += val;
    pos += pos & (-pos);
  }
}
long long query(int pos, int ind) {
  long long res = 0;
  pos++;
  while (pos) {
    res += fenwick[ind][pos];
    pos -= pos & (-pos);
  }
  return res;
}
void read() {
  cin >> n;
  vector<pair<int, int> > xv(n);
  for (int i = 0; i < n; i++) {
    cin >> xv[i].first;
  }
  for (int i = 0; i < n; i++) {
    cin >> xv[i].second;
  }
  vector<int> tmp;
  for (int i = 0; i < n; i++) tmp.push_back(xv[i].second);
  sort(tmp.begin(), tmp.end());
  auto it = unique(tmp.begin(), tmp.end());
  tmp.resize(distance(tmp.begin(), it));
  map<int, int> M;
  for (int i = 0; i < tmp.size(); i++) {
    M[tmp[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    xv[i].second = M[xv[i].second];
  }
  sort(xv.begin(), xv.end());
  int N = n;
  n = tmp.size();
  fenwick[0].resize(n + 1);
  fenwick[1].resize(n + 1);
  for (auto& el : fenwick[0]) el = 0;
  for (auto& el : fenwick[1]) el = 0;
  long long res = 0;
  for (int i = 0; i < N; i++) {
    res += xv[i].first * query(xv[i].second, 0) - query(xv[i].second, 1);
    add(xv[i].second, 1, 0);
    add(xv[i].second, xv[i].first, 1);
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  srand(time(NULL));
  int T = 1;
  prep();
  for (int i = 1; i <= T; i++) {
    read();
    solve();
  }
  return 0;
}

```