from heapq import heappush, heappop N = int(input()) H = sorted(list(map(int, input().split()))) MAX = max(H[i].bit_length()-i-1 for i in range(N)) que = [] for h in H: heappush(que, -h) cnt = MAX+N-1 for _ in range(MAX+N): if not que: break n = -heappop(que) n -= 1<