Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2^{w}_{i} pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does this until there's no more weight left. Malek asked her to minimize the number of steps. [Image] 

Duff is a competitive programming fan. That's why in each step, she can only lift and throw away a sequence of weights 2^{a}_1, ..., 2^{a}_{k} if and only if there exists a non-negative integer x such that 2^{a}_1 + 2^{a}_2 + ... + 2^{a}_{k} = 2^{x}, i. e. the sum of those numbers is a power of two.

Duff is a competitive programming fan, but not a programmer. That's why she asked for your help. Help her minimize the number of steps. 


-----Input-----

The first line of input contains integer n (1 ≤ n ≤ 10^6), the number of weights.

The second line contains n integers w_1, ..., w_{n} separated by spaces (0 ≤ w_{i} ≤ 10^6 for each 1 ≤ i ≤ n), the powers of two forming the weights values.


-----Output-----

Print the minimum number of steps in a single line.


-----Examples-----
Input
5
1 1 2 3 3

Output
2

Input
4
0 1 2 3

Output
4



-----Note-----

In the first sample case: One optimal way would be to throw away the first three in the first step and the rest in the second step. Also, it's not possible to do it in one step because their sum is not a power of two.

In the second sample case: The only optimal way is to throw away one weight in each step. It's not possible to do it in less than 4 steps because there's no subset of weights with more than one weight and sum equal to a power of two.

Difficulty: competition

Starter code:

Solutions:
n = int(input())
a = [int(x) for x in input().split()]
l = [0] * (10**6 + 100)
for x in a:
	l[x] += 1
cur = 0
ans = 0
for x in l:
	cur += x
	if cur % 2:
		ans += 1
	cur //= 2
print(ans)


n = input()
a = [0] * 1000021
ans = 0
b = 0

for u in map(int, input().split()):
    a[u] += 1

for u in a:
    b += u
    if b & 1:
        ans += 1
    b >>= 1

print(ans)

from sys import stdin
stdin.readline()
a = [0] * 1000021
ans = b = 0
for u in map(int, stdin.readline().split()):
    a[u] += 1
for u in a:
    b += u
    ans += b&1
    b >>= 1
print(ans)

def main():
    input()
    l = [0] * 1000020
    for w in map(int, input().split()):
        l[w] += 1
    for w, x in enumerate(l):
        if x:
            l[w] = x & 1
            while x:
                x >>= 1
                w += 1
                if x & 1:
                    l[w] += 1
    print(sum(l))


def __starting_point():
    main()
__starting_point()

def main():
    n = int(input())
    w = list(map(int, input().split()))
    bits = [0] * (10 ** 6 + 100)
    for e in w:
        bits[e] += 1
    cur, res = 0, 0
    for e in bits:
        cur += e
        if cur % 2:
            res += 1
        cur //= 2
    print(res)


def __starting_point():
    main()

__starting_point()

n = int(input())
l = [0] * (10**6+100)
for i in map(int,input().split()):
    l[i] += 1
cur = ans = 0
for i in l:
    cur += i
    if cur%2:
        ans += 1
    cur //=2
print (ans)


# Description of the problem can be found at http://codeforces.com/problemset/problem/587/A

n = int(input())
w = map(int, input().split())
m = 1000001
s = [0] * m

for i in w:
    s[i] += 1

ans = 0
z = 0
for i in range(m):
    n_s = s[i]+z
    z = n_s // 2
    ans += n_s % 2

while z > 0:
    ans += z % 2
    z //= 2

print(ans)

n = int(input())

l = [0] * (10**6+100)

for i in map(int,input().split()):

    l[i] += 1

cur = ans = 0

for i in l:

    cur += i

    if cur%2:

        ans += 1

    cur //=2

print (ans)





# Made By Mostafa_Khaled


l=[0]*1100001
input()
for i in map(int,input().split()):l[i]+=1
for i in range(1100000):
    l[i],l[i+1]=l[i]%2,l[i+1]+l[i]//2
print(sum(l))

n = int(input())
num = [0] * (2 * (10 ** 6) + 1)
for i in map(int, input().split()):
    num[i] += 1
ans = 0
for i in range(2 * (10 ** 6)):
    num[i + 1] += num[i] // 2
    ans += num[i] % 2
print(ans + num[-1] % 2)

n = int(input())
MAXN = 10**6 + 20
bit = [0]*MAXN
for s in input().split(' '):
    ss = int(s)
    bit[ss] += 1
    while bit[ss] > 1:
        bit[ss+1] += 1
        bit[ss] = bit[ss] & 1
        ss += 1
print(sum(bit))


N = int(1e6+100)
n = int(input())
arr = list(map(int, input().split()))
cnt = [0] * N
for i in arr:
    cnt[i] += 1
res, s = 0, 0
for i in range(N):
    s += cnt[i]
    res += s % 2
    s //= 2
print(res)


N = int(1e6+3)
n = int(input())
arr = list(map(int, input().split()))
cnt = [0] * N
for i in arr:
    cnt[i] += 1
res, s = 0, 0
for i in range(N):
    s += cnt[i]
    res += s % 2
    s //= 2
while s > 0:
    res += s % 2
    s //= 2
print(res)


import math

n = int(input())

w = [int(i) for i in input().split()]
# w = [1000000] * 1000000
mxN = 1000000 + math.ceil(math.log2(1000000)) + 1

btStr = [0] * mxN

# print(btStr)
# mx = 0

for i in w:
    btStr[i] += 1
    # print(j)

# print(mx)
steps = 0

for i in range(mxN - 1):
    btStr[i + 1] += btStr[i] // 2
    btStr[i] = btStr[i] % 2
    steps += btStr[i]

# for i in btStr:
#     if i == 1:
#         steps += 1
#
print(steps)


def ok(x):
	if x==0:
		return False
	return x&(x-1)
n=int(input())
arr=list(map(int,input().split()))
f=[0]*(2000020)
for i in arr:
	f[i]+=1
ans=0
for i in range(2000010):
	if f[i]%2==1:
		ans+=1
		f[i]-=1
	f[i+1]+=(f[i]//2)
print(ans)

n=int(input())
a=list(map(int, input().split()))
di=[0]*(10**6+699)
for i in a:
    di[i]+=1

ans=0
for i in range(10**6+698): 
    di[i], di[i+1] = di[i] % 2, di[i+1] + di[i] // 2
    if di[i] % 2 == 1: ans += 1

#print(di[:3])
print(ans)

n = int(input())
 
l = [0] * (10**6+100)
 
for i in map(int,input().split()):
 
    l[i] += 1
 
cur = ans = 0
 
for i in l:
 
    cur += i
 
    if cur%2:
 
        ans += 1
 
    cur //=2
 
print (ans)


n = int(input())
lis = list(map(int,input().split()))
has=[0]*(1000500)
ans=0
for i in lis:
    has[i]+=1
for i in range(1000499):
    has[i+1]+=(has[i]//2)
    if(has[i]%2!=0):
        ans+=1
print(ans)            

from collections import Counter,defaultdict,deque
import heapq as hq
#import itertools
#from operator import itemgetter
#from itertools import count, islice
#from functools import reduce
#alph = 'abcdefghijklmnopqrstuvwxyz'
#from math import factorial as fact
#a,b = [int(x) for x in input().split()]
#sarr = [x for x in input().strip().split()]
import math
import sys
input=sys.stdin.readline
def solve():
    n = int(input())
    
    c=[0]*(10**6+1000)
    for el in (int(x) for x in input().split()):
        c[el]+=1
    res = 0
    for i in range(10**6+999):
        c[i+1]+=c[i]//2
        res+=c[i]%2
    print(res)

tt = 1#int(input())
for test in range(tt):
    solve()















#


import sys
input = sys.stdin.readline
print = sys.stdout.write
n = int(input())
two = [0] * (10**6 + 100)
for i in map(int,input().split()):
	two[i]+= 1
res = 0
for i in range(10**6+99):
	two[i + 1]+= two[i] // 2
	two[i] %=2
	res+= two[i]
print(str(res))


n = input()
a = [0] * 1000021
ans = 0
b = 0
 
for u in map(int, input().split()):
    a[u] += 1
 
for u in a:
    b += u
    if b & 1:
        ans += 1
    b >>= 1
 
print(ans)

from collections import defaultdict

mxn = 10**6
n = int(input())
a = list(map(int, input().split()))
d = [0]*(mxn+2)

for i in a:
    d[i] += 1
    
for i in range(1+mxn):
    q = d[i]//2
    d[i+1] += q
    d[i] -= 2*q
    
ct = 0
for i in d:
    ct += bin(i).count("1")
print(ct)

n=int(input())
A=list(map(int,input().split()))

d={}
for i in range(n):
    if A[i] in d:
        k=A[i]
        while k in d:
            del d[k]
            k+=1
        d[k]=1
    else:
        d[A[i]]=1
    
print(len(d))

n=int(input())
l=list(map(int,input().split()))
cnt=[0]*(10**6+100)
for i in l:
  cnt[i]+=1
s=0
ans=0
for i in cnt:
 s+=i
 ans+=s%2
 s//=2
print(ans)


import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))
K = 100+max(A)
L = [0]*K
for a in A:
    L[a] += 1

for i in range(K):
    if L[i] > 1:
        L[i+1] += L[i]//2
        L[i] = L[i]%2
print(sum(L))