# coding: utf-8 import heapq N = int(raw_input()) A = map(int, raw_input().split()) B = map(int, raw_input().split()) Aheap = [] for i in range(len(A)): heapq.heappush(Aheap, (A[i], 0)) B = [int(b)/2 for b in B] B_ = list(B) B.extend(B_) ans = int(1e9+7) for i in range(len(B_)): a = list(Aheap) for j in range(len(B_)): lv, c = a[0] #print str(lv) + ' ' + str(c) heapq.heapreplace(a, (lv+B[i+j], c+1)) #print a ans=min(ans, max(c for lv, c in a)) print ans