n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) from heapq import heappush,heappop def solve(a,b): q=[(v,0) for v in a] q.sort() for u in b: v,c=heappop(q) v+=u//2 c+=1 heappush(q,(v,c)) q=list(q) return max(c for v,c in q) ans=10**10 for i in range(n): ans=min(ans,solve(a,b[i:]+b[:i])) print(ans)