import sys input = sys.stdin.readline from heapq import * from copy import deepcopy n = int(input()) ans = 1 << 30 p = [(l, 0) for l in map(int, input().split())] heapify(p) enemies = list(map(int, input().split())) for s in range(n): party = deepcopy(p) for i in range(n): l, t = heappop(party) heappush(party, (l + enemies[(s + i) % n] // 2, t + 1)) ans = min(ans, max(x for _, x in party)) print(ans)