from heapq import * N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 for i in range(N): hq = [] for j in A: hq.append((j, 0)) for k in range(N): c = B[(i + k) % N] ns, cnt = heappop(hq) heappush(hq, (ns + c // 2, cnt + 1)) ans = max(ans, max(hq[i][1] for i in range(N))) print(ans)