def solve(): import sys input = sys.stdin.read data = list(map(int, input().split())) N = data[0] H = data[1:] H.sort() p = 1 ans = 0 from heapq import heappush,heappop,heapify heapify(H) while H: u=heappop(H) u-=p p<<=1 if u>0:heappush(H,u) ans+=1 print(ans) solve()