import heapq N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) def solve(N, A, B): record = N BB = B + B pq0 = [(a, 0) for a in A] heapq.heapify(pq0) for i in range(N): pq = pq0[:] for b in BB[i:i + N]: a, n = pq[0] heapq.heapreplace(pq, (a + b//2, n + 1)) max_n = max(n for a, n in pq) if max_n < record: record = max_n return record print(solve(N, A, B))