from heapq import heappush, heappop, heapify n = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) ans = 10**10 base = [(a,0) for a in A] heapify(base) for i in range(n): h = base.copy() for j in range(n): a,num = heappop(h) a += B[(i+j)%n]//2 heappush(h, (a,num+1)) m = max(i for _,i in h) ans = min(ans,m) print(ans)