from heapq import * n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) ret = 0 for i in range(n): pq = [(x, 0) for x in a] heapify(pq) for j in range(n): e = b[(i + j) % n] u = heappop(pq) u = (u[0] + e // 2, u[1] + 1) heappush(pq, u) for e in pq: ret = max(ret, e[1]) print(ret)