from heapq import heappush, heappop import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = float('inf') for i in range(N): heap = [] for j in range(N): heappush(heap, (A[j], 0)) for j in range(N): level, cnt = heappop(heap) level += B[(i+j)%N] // 2 cnt += 1 heappush(heap, (level, cnt)) ans = min(ans, max(cnt for val, cnt in heap)) print(ans)