from heapq import heappush, heappop N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 10**18 for i in range(N): pq = [] for j in range(N): heappush(pq, (A[j], 0)) for j in range(N): level, cnt = heappop(pq) level += B[(i+j)%N]//2 cnt += 1 heappush(pq, (level, cnt)) ans = min(ans, max(cnt for _, cnt in pq)) print(ans)