993_D. Compute Power
You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume.

You have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one task at a time, and no more than two tasks total. The first task can be any, the second task on each computer must use strictly less power than the first. You will assign between 1 and 2 tasks to each computer. You will then first execute the first task on each computer, wait for all of them to complete, and then execute the second task on each computer that has two tasks assigned.

If the average compute power per utilized processor (the sum of all consumed powers for all tasks presently running divided by the number of utilized processors) across all computers exceeds some unknown threshold during the execution of the first tasks, the entire system will blow up. There is no restriction on the second tasks execution. Find the lowest threshold for which it is possible.

Due to the specifics of the task, you need to print the answer multiplied by 1000 and rounded up.

Input

The first line contains a single integer n (1 ≤ n ≤ 50) — the number of tasks.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 108), where ai represents the amount of power required for the i-th task.

The third line contains n integers b1, b2, ..., bn (1 ≤ bi ≤ 100), where bi is the number of processors that i-th task will utilize.

Output

Print a single integer value — the lowest threshold for which it is possible to assign all tasks in such a way that the system will not blow up after the first round of computation, multiplied by 1000 and rounded up.

Examples

Input

6
8 10 9 9 8 10
1 1 1 1 1 1


Output

9000


Input

6
8 10 9 9 8 10
1 10 5 5 1 10


Output

1160

Note

In the first example the best strategy is to run each task on a separate computer, getting average compute per processor during the first round equal to 9.

In the second task it is best to run tasks with compute 10 and 9 on one computer, tasks with compute 10 and 8 on another, and tasks with compute 9 and 8 on the last, averaging (10 + 10 + 9) / (10 + 10 + 5) = 1.16 compute power per processor during the first round.
```python
#     Codeforces Round #488 by NEAR (Div. 2)
import collections
from functools import cmp_to_key
#key=cmp_to_key(lambda x,y: 1 if x not in y else -1 )
import math
import sys
def getIntList():
    return list(map(int, input().split()))    

import bisect 

def makePair(z):
    return  [(z[i], z[i+1]) for i in range(0,len(z),2) ]
            
N, =  getIntList()
za = getIntList() 
zb = getIntList()
 
sa = set(za)

xa = list(sa)
xa.sort(reverse = True)

zz = [(t, sorted([zb[i]  for i in range(N) if za[i] == t]) )  for t in xa ]
#print(zz)


lastdp = [[] for i in range(52)]
lastdp[0] = [(0,0)]


def addres(z, t):
    if len(z) ==0:
        z.append(t)
        return
    i = bisect.bisect_right(z,t)
    if i>0 and z[i-1][1] >= t[1]: return
    if i<len(z) and t[1] >= z[i][1]:
        z[i] = t
        return
    z.insert(i,t)
    

for x in zz:
    nowdp  = [[] for i in range(52)]
    for i in range(len(lastdp)):
        tz = lastdp[i]
        if len( tz ) ==0 : continue
        num = len(x[1])
        hide = min(i, num )
        
        tb = sum(x[1])
        acc =0;
        
        for j in range(hide + 1):
            la = x[0] * (num-j)
            lb = tb - acc
            if j<num: acc += x[1][j]
            for t in tz:
                # t = (0,0)
                tr = (t[0] + la, t[1] + lb)
                addres(nowdp[ i -j + num -j] ,tr)
    lastdp = nowdp
    #print(lastdp)

res = 10 ** 20
for x in lastdp:
    for y in x:
        t = math.ceil(y[0] *1000   /  y[1] )
        res = min( res,t)

print(res)

```