def binary_search(f): left,right=0,10**5 + 80 while right-left>1: mid=(right+left)//2 if f(mid): right=mid else: left=mid return right def f(x): hq = [-h for h in H] heapq.heapify(hq) for i in range(x-1,-1,-1): if len(hq) == 0: break if i>=60: t = 2**60 else: t = 2**i p = heapq.heappop(hq) p += t if p<0: heapq.heappush(hq, p) if len(hq) == 0: return True return False import heapq N=int(input()) H=list(map(int,input().split())) print(binary_search(f))