# coding: utf-8 import heapq N = int(input()) A = list(map(int, input().split())) B = [int(x)/2 for x in input().split()] A.sort() Aheap = [(a, 0) for a in A] B_ = list(B) B.extend(B_) ans = int(1e9+7) for i in range(len(B_)): a = list(Aheap) for j in range(len(B_)): lv, c = a[0] #print str(lv) + ' ' + str(c) heapq.heapreplace(a, (lv+B[i+j], c+1)) #print a ans=min(ans, max(c for lv, c in a)) print(ans)