#include <bits/stdc++.h>
using namespace std;
int n;
struct dd {
  int gt;
  int x;
  int v;
};
vector<dd> a;
struct Data {
  long long sum;
  int sl;
};
Data it[200009 * 8];
Data ans;
long long res;
void update(int i, int l, int r, int pos, int data) {
  if (l > pos || r < pos) return;
  if (l == r) {
    it[i].sum = data;
    it[i].sl = 1;
    return;
  }
  int mid = (l + r) / 2;
  update(i * 2, l, mid, pos, data);
  update(i * 2 + 1, mid + 1, r, pos, data);
  it[i].sum = it[i * 2].sum + it[i * 2 + 1].sum;
  it[i].sl = it[i * 2].sl + it[i * 2 + 1].sl;
}
void find(int i, int l, int r, int u, int v) {
  if (l > r) return;
  if (r < u || l > v) return;
  if (u <= l && r <= v) {
    ans.sum = ans.sum + it[i].sum;
    ans.sl = ans.sl + it[i].sl;
    return;
  }
  int mid = (l + r) / 2;
  find(i * 2, l, mid, u, v);
  find(i * 2 + 1, mid + 1, r, u, v);
}
bool cmp(const dd& a, const dd& b) {
  if (a.v == b.v) {
    return a.x < b.x;
  }
  return a.v < b.v;
}
bool cmp1(const dd& a, const dd& b) { return a.x < b.x; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    dd tmp;
    cin >> tmp.x;
    a.push_back(tmp);
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i].v;
  }
  sort(a.begin(), a.end(), cmp1);
  for (int i = 0; i < n; i++) {
    a[i].gt = i + 1;
  }
  sort(a.begin(), a.end(), cmp);
  update(1, 1, n, a[n - 1].gt, a[n - 1].x);
  for (int i = n - 2; i >= 0; i--) {
    long long tmp = a[i].x;
    ans.sl = 0;
    ans.sum = 0;
    find(1, 1, n, a[i].gt + 1, n);
    res = res + ans.sum - (tmp * ans.sl);
    update(1, 1, n, a[i].gt, a[i].x);
  }
  cout << res << endl;
}

### Prompt

Your task is to create a cpp solution to 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;
struct dd {
  int gt;
  int x;
  int v;
};
vector<dd> a;
struct Data {
  long long sum;
  int sl;
};
Data it[200009 * 8];
Data ans;
long long res;
void update(int i, int l, int r, int pos, int data) {
  if (l > pos || r < pos) return;
  if (l == r) {
    it[i].sum = data;
    it[i].sl = 1;
    return;
  }
  int mid = (l + r) / 2;
  update(i * 2, l, mid, pos, data);
  update(i * 2 + 1, mid + 1, r, pos, data);
  it[i].sum = it[i * 2].sum + it[i * 2 + 1].sum;
  it[i].sl = it[i * 2].sl + it[i * 2 + 1].sl;
}
void find(int i, int l, int r, int u, int v) {
  if (l > r) return;
  if (r < u || l > v) return;
  if (u <= l && r <= v) {
    ans.sum = ans.sum + it[i].sum;
    ans.sl = ans.sl + it[i].sl;
    return;
  }
  int mid = (l + r) / 2;
  find(i * 2, l, mid, u, v);
  find(i * 2 + 1, mid + 1, r, u, v);
}
bool cmp(const dd& a, const dd& b) {
  if (a.v == b.v) {
    return a.x < b.x;
  }
  return a.v < b.v;
}
bool cmp1(const dd& a, const dd& b) { return a.x < b.x; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    dd tmp;
    cin >> tmp.x;
    a.push_back(tmp);
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i].v;
  }
  sort(a.begin(), a.end(), cmp1);
  for (int i = 0; i < n; i++) {
    a[i].gt = i + 1;
  }
  sort(a.begin(), a.end(), cmp);
  update(1, 1, n, a[n - 1].gt, a[n - 1].x);
  for (int i = n - 2; i >= 0; i--) {
    long long tmp = a[i].x;
    ans.sl = 0;
    ans.sum = 0;
    find(1, 1, n, a[i].gt + 1, n);
    res = res + ans.sum - (tmp * ans.sl);
    update(1, 1, n, a[i].gt, a[i].x);
  }
  cout << res << endl;
}

```