import heapq from collections import deque from copy import deepcopy d = deque() n = int(input()) a = [] for i in (input().split()): heapq.heappush(a,[int(i),0]) b = deque(list(map(int, input().split()))) c = n ans = 0xFFFFFFFF while (c): tmp = deepcopy(a) mx = 0 for bb in b: t = heapq.heappop(tmp) t[0] += bb // 2 t[1] += 1 heapq.heappush(tmp, t) mx = max(mx, t[1]) c -= 1 ans = min(ans, mx) b.rotate(1) print(ans)