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