Home => ProblemSet => 3.2-70:[CF1311F]Moving Points
Problem2073--3.2-70:[CF1311F]Moving Points

2073: 3.2-70:[CF1311F]Moving Points

Time Limit: 2 Sec  Memory Limit: 256 MB  Submit: 0  Solved: 1
[ Submit ] [ Status ] [ Creator: ][ 参考程序 ]

Description

There are n points on a coordinate axis OX. The i-th point is located at the integer point xi and has a speed vi. 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 (can be non-integer) is calculated as xi+t⋅vi.

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⋅105) — the number of points.

The second line of the input contains n integers x1,x2,…,xn (1≤xi≤108), where xi is the initial coordinate of the i-th point. It is guaranteed that all xi are distinct.

The third line of the input contains n integers v1,v2,…,vn (−108≤vi≤108), where vi is the speed of the i-th point.

Output

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

Sample Input Copy

3
1 3 2
-100 2 3

Sample Output Copy

3

HINT

样例二:
输入:
5
2 1 4 3 5
2 2 2 3 4
输出:
19


样例三:
输入:

2 1 
-3 0
输出:
0




Source/Category