557_C. Arthur and Table
Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable.

In total the table Arthur bought has n legs, the length of the i-th leg is li.

Arthur decided to make the table stable and remove some legs. For each of them Arthur determined number di — the amount of energy that he spends to remove the i-th leg.

A table with k legs is assumed to be stable if there are more than half legs of the maximum length. For example, to make a table with 5 legs stable, you need to make sure it has at least three (out of these five) legs of the maximum length. Also, a table with one leg is always stable and a table with two legs is stable if and only if they have the same lengths.

Your task is to help Arthur and count the minimum number of energy units Arthur should spend on making the table stable.

Input

The first line of the input contains integer n (1 ≤ n ≤ 105) — the initial number of legs in the table Arthur bought.

The second line of the input contains a sequence of n integers li (1 ≤ li ≤ 105), where li is equal to the length of the i-th leg of the table.

The third line of the input contains a sequence of n integers di (1 ≤ di ≤ 200), where di is the number of energy units that Arthur spends on removing the i-th leg off the table.

Output

Print a single integer — the minimum number of energy units that Arthur needs to spend in order to make the table stable.

Examples

Input

2
1 5
3 2


Output

2


Input

3
2 4 4
1 1 1


Output

0


Input

6
2 2 1 1 3 3
4 3 5 5 2 1


Output

8
```python
"""
	Author		: Arif Ahmad
	Date  		: 
	Algo  		: 
	Difficulty	: 
"""
from sys import stdin, stdout

def main():
	n 	= int(stdin.readline())
	leg	= [int(_) for _ in stdin.readline().split()]
	d 	= [int(_) for _ in stdin.readline().split()]

	pairedLD = []
	for x, y in zip(leg, d):
		pairedLD.append((x, y))
	pairedLD = sorted(pairedLD)

	legSet 		= set()
	suffixSum  	= dict()
	legFreq		= dict()
	for length, energy in zip(leg, d):
		legSet.add(length)
		if length in suffixSum: 
			suffixSum[length] += energy
			legFreq[length] += 1
		else: 
			suffixSum[length] = energy
			legFreq[length] = 1
		

	legList = [x for x in legSet]
	legList = sorted(legList, reverse=True)
	total 	= 0
	for length in legList:
		suffixSum[length] += total
		total = suffixSum[length]

	ans = int(2e7)
	toRemove = 0
	available = 0
	removable = [0] * 201
	legList = sorted(legList)
	listLen = len(legList)
	idx = 0
	for i in range(listLen):
		curr = 0
		if i+1 < listLen: curr += suffixSum[legList[i+1]]
		toRemove = available - (legFreq[legList[i]] - 1)
		if toRemove < 0: toRemove = 0
		for j in range(1, 201):
			if removable[j] != 0 and removable[j] <= toRemove:
				curr += (removable[j] * j)
				toRemove -= removable[j]
			elif removable[j] > toRemove:
				curr += (toRemove * j)
				toRemove = 0
			if toRemove == 0: break
		available += legFreq[legList[i]]
		for j in range(legFreq[legList[i]]): 
			removable[pairedLD[idx][1]] += 1
			idx += 1
		ans = min(ans, curr)

	print(ans)


if __name__ == '__main__':
    main()
    
```