VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications.

The latest A/B test suggests that users are reading recommended publications more actively if each category has a different number of publications within daily recommendations. The targeted algorithm can find a single interesting publication of i-th category within t_i seconds. 

What is the minimum total time necessary to add publications to the result of batch algorithm execution, so all categories have a different number of publications? You can't remove publications recommended by the batch algorithm.

Input

The first line of input consists of single integer n — the number of news categories (1 ≤ n ≤ 200 000).

The second line of input consists of n integers a_i — the number of publications of i-th category selected by the batch algorithm (1 ≤ a_i ≤ 10^9).

The third line of input consists of n integers t_i — time it takes for targeted algorithm to find one new publication of category i (1 ≤ t_i ≤ 10^5).

Output

Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.

Examples

Input


5
3 7 9 7 8
5 2 5 7 5


Output


6


Input


5
1 2 3 4 5
1 1 1 1 1


Output


0

Note

In the first example, it is possible to find three publications of the second type, which will take 6 seconds.

In the second example, all news categories contain a different number of publications.
import java.io.*;
import java.util.*;
import java.math.*;

public class D {

	public class Pair1 implements Comparable<Pair1> {
		public int numpubs;
		public PriorityQueue<Rev> t;

		public Pair1 (int numpubs, PriorityQueue<Rev> t) {
			this.numpubs = numpubs;
			this.t = t;
		}

		public int compareTo(Pair1 p) {
			if(this.numpubs < p.numpubs) {
				return -1;
			} else if(this.numpubs == p.numpubs) {
				return 0;
			}

			return 1;
		}

		public String toString() {
			return numpubs + ": " + t.toString();
		}
			
	}

	public class Rev implements Comparable<Rev> {
		public long t;
		public int startingpoint;

		public Rev(long t, int startingpoint) {
			this.t = t;
			this.startingpoint = startingpoint;
		}

		public int compareTo(Rev r) {
			if(this.t > r.t) {
				return -1;
			} else if(this.t == r.t) {
				return 0;
			}

			return 1;
		}
		
		public String toString() {
			return t + ", " + startingpoint;
		}
	}


	public void realMain() throws Exception {
		//System.err.println(System.currentTimeMillis());
		BufferedReader fin = new BufferedReader(new InputStreamReader(System.in), 1000000);

		String in = fin.readLine();

		String[] ar = in.split(" ");

		int n = Integer.parseInt(ar[0]);
		
		int[] a = new int[n];

		for(int i = 0; i < n; i++) {
			int ret = 0;
			boolean dig = false;
			for (int ch = 0; (ch = fin.read()) != -1; ) {
        			if (ch >= '0' && ch <= '9') {
            				dig = true;
           				ret = ret * 10 + ch - '0';
        			} else if (dig) break;
    			}

			a[i] = ret;
			
		}

		int[] b = new int[n];

		
		for(int i = 0; i < n; i++) {
			int ret = 0;
			boolean dig = false;
			for (int ch = 0; (ch = fin.read()) != -1; ) {
        			if (ch >= '0' && ch <= '9') {
            				dig = true;
           				ret = ret * 10 + ch - '0';
        			} else if (dig) break;
    			}

			b[i] = ret;
			
		}

		//System.err.println(System.currentTimeMillis());

		HashMap<Integer, PriorityQueue<Rev>> hm = new HashMap<Integer, PriorityQueue<Rev>>();

		for(int i = 0; i < n; i++) {
			if(hm.containsKey(a[i])) {
				/*PriorityQueue<Rev> pq2 = new PriorityQueue<Rev>(hm.get(a[i]));
				pq2.add(new Rev(b[i], a[i]));
				hm.put(a[i], pq2);
*/
				hm.get(a[i]).add(new Rev(b[i], a[i]));

			} else {
				PriorityQueue<Rev> pq = new PriorityQueue<Rev>();
				pq.add( new Rev(b[i], a[i]));
				hm.put(a[i], pq);
			}
		}

//System.err.println(System.currentTimeMillis());


		ArrayList<Pair1> pairs = new ArrayList<Pair1>();

		for(Map.Entry<Integer, PriorityQueue<Rev>> entry : hm.entrySet()) {
			pairs.add( new Pair1( entry.getKey(), entry.getValue() ) );
		}

		Collections.sort(pairs);

		long ans = 0;

		////System.err.println(pairs.toString());

		//System.err.println(System.currentTimeMillis());

		for(int ind = 0; ind < pairs.size(); ind++) {
			int cnt = pairs.get(ind).t.size();

			int start = pairs.get(ind).numpubs;

			if(cnt < 2) {
				continue;
			}

			int end = start;

			int cur = start;

			int newind = ind;
			
			while(cnt > 1) {
				cur++;

				if(hm.containsKey(cur)) {
					cnt += hm.get(cur).size();
					newind++;
				}
				cnt--;
				end = cur;
			}

			end--;

			PriorityQueue<Rev> curpq = pairs.get(ind).t;

		//System.err.println(System.currentTimeMillis());

			for(int i = start; i <= end + 1; i++) {
				Rev nexttake = curpq.poll();

				ans += nexttake.t * (i - nexttake.startingpoint);

				if(hm.containsKey(i + 1)) {
					curpq.addAll(hm.get(i + 1));
				}
			}

			ind = newind;
		}

		System.out.println(ans);

			
		//System.err.println(System.currentTimeMillis());

	}


	public static void main(String[] args) throws Exception {
		D d = new D();
		d.realMain();
	}
}