from heapq import heappop, heappush N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) res = float('inf') for i in range(N): h = [] cnt = 0 for j in range(N): heappush(h,(A[j],0)) for j in range(N): b = B[(i+j)%N] lev, num = heappop(h) cnt = max(cnt,num+1) heappush(h,(lev+b//2,num+1)) res = min(res, cnt) print(res)