import heapq N = int(input()) A = [int(i) for i in input().split()] B = [int(i) for i in input().split()] ans = 10 ** 9 + 7 for i in range(N): pq = [(j,0) for j in A] heapq.heapify(pq) battle = 0 for j in range(N): p = heapq.heappop(pq) next = (p[0] + (B[(i + j) % N]//2),p[1] + 1) battle = max(battle,next[1]) heapq.heappush(pq,next) ans = min(ans,battle) print(ans)