#include <bits/stdc++.h>
using namespace std;
int n;
long long f1[200005], f2[200005], kc;
pair<long long, long long> a[200005];
bool cmp1(pair<long long, long long> x, pair<long long, long long> y) {
  return x.first < y.first;
}
bool cmp2(pair<long long, long long> x, pair<long long, long long> y) {
  return x.second < y.second;
}
void update(int id, long long value, long long f[]) {
  while (id < 200005) {
    f[id] = f[id] + value;
    id = id + (id & -id);
  };
}
long long rsumq(int x, long long f[]) {
  long long sum = 0;
  while (x != 0) {
    sum += f[x];
    x -= (x & -x);
  };
  return sum;
}
long long rsumq(int x, int y, long long f[]) {
  return rsumq(y, f) - (x == 1 ? 0 : rsumq(x - 1, f));
}
void nhap() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].first;
  for (int i = 1; i <= n; i++) cin >> a[i].second;
  sort(a + 1, a + 1 + n, cmp2);
  int cnt = 1;
  for (int i = 1; i < n; i++) {
    int tmp = a[i].second;
    a[i].second = cnt;
    if (tmp != a[i + 1].second) cnt++;
  }
  a[n].second = cnt;
}
void xuly() {
  sort(a + 1, a + 1 + n, cmp1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (rsumq(1, a[i].second, f1) * a[i].first - rsumq(1, a[i].second, f2));
    update(a[i].second, 1, f1);
    update(a[i].second, a[i].first, f2);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  nhap();
  xuly();
  return 0;
}

### Prompt

Create a solution in Cpp for 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;
int n;
long long f1[200005], f2[200005], kc;
pair<long long, long long> a[200005];
bool cmp1(pair<long long, long long> x, pair<long long, long long> y) {
  return x.first < y.first;
}
bool cmp2(pair<long long, long long> x, pair<long long, long long> y) {
  return x.second < y.second;
}
void update(int id, long long value, long long f[]) {
  while (id < 200005) {
    f[id] = f[id] + value;
    id = id + (id & -id);
  };
}
long long rsumq(int x, long long f[]) {
  long long sum = 0;
  while (x != 0) {
    sum += f[x];
    x -= (x & -x);
  };
  return sum;
}
long long rsumq(int x, int y, long long f[]) {
  return rsumq(y, f) - (x == 1 ? 0 : rsumq(x - 1, f));
}
void nhap() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].first;
  for (int i = 1; i <= n; i++) cin >> a[i].second;
  sort(a + 1, a + 1 + n, cmp2);
  int cnt = 1;
  for (int i = 1; i < n; i++) {
    int tmp = a[i].second;
    a[i].second = cnt;
    if (tmp != a[i + 1].second) cnt++;
  }
  a[n].second = cnt;
}
void xuly() {
  sort(a + 1, a + 1 + n, cmp1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (rsumq(1, a[i].second, f1) * a[i].first - rsumq(1, a[i].second, f2));
    update(a[i].second, 1, f1);
    update(a[i].second, a[i].first, f2);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  nhap();
  xuly();
  return 0;
}

```