from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) B += B Y = [(b,0) for b in A] heapify(Y) ans = N for i in range(N): h = Y[:] tans = 0 for j in range(N): a = B[i+j] x,c = heappop(h) x += a//2 c += 1 tans = max(tans,c) heappush(h,(x,c)) ans = min(ans,tans) print(ans)