import heapq n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) b *= 2 ans = n for i in range(n): que = [[a[x], 0] for x in range(n)] heapq.heapify(que) cnt = 0 for j in range(n): pos = i + j h = heapq.heappop(que) h[0] += b[pos] // 2 h[1] += 1 heapq.heappush(que, h) cnt = max(cnt, h[1]) ans = min(ans, cnt) print(ans)