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 mn = 0xFFFFFFFF count = 0 for bb in b: t = heapq.heappop(tmp) t[0] += bb >> 1 t[1] += 1 mx = max(mx, t[1]) if mx >= ans: break heapq.heappush(tmp, t) c -= 1 ans = min(ans, mx) b.rotate(1) print(ans)