import heapq from types import LambdaType n = int(input()) allies = list(map(int, input().split())) enemies = list(map(lambda x: int(x) // 2, input().split())) ans = n + 1 for s in range(n): que = [(allies[i], 0) for i in range(n)] heapq.heapify(que) temp = 0 for j in range(n): u = heapq.heappop(que) heapq.heappush(que, (u[0] + enemies[(s + j) % n], u[1] + 1)) temp = max(temp, u[1] + 1) ans = min(ans, temp) print(ans)