You are given a sequence of positive integers a_1, a_2, ..., a_{n}. 

While possible, you perform the following operation: find a pair of equal consecutive elements. If there are more than one such pair, find the leftmost (with the smallest indices of elements). If the two integers are equal to x, delete both and insert a single integer x + 1 on their place. This way the number of elements in the sequence is decreased by 1 on each step. 

You stop performing the operation when there is no pair of equal consecutive elements.

For example, if the initial sequence is [5, 2, 1, 1, 2, 2], then after the first operation you get [5, 2, 2, 2, 2], after the second — [5, 3, 2, 2], after the third — [5, 3, 3], and finally after the fourth you get [5, 4]. After that there are no equal consecutive elements left in the sequence, so you stop the process.

Determine the final sequence after you stop performing the operation.


-----Input-----

The first line contains a single integer n (2 ≤ n ≤ 2·10^5) — the number of elements in the sequence.

The second line contains the sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9).


-----Output-----

In the first line print a single integer k — the number of elements in the sequence after you stop performing the operation. 

In the second line print k integers — the sequence after you stop performing the operation.


-----Examples-----
Input
6
5 2 1 1 2 2

Output
2
5 4 
Input
4
1000000000 1000000000 1000000000 1000000000

Output
1
1000000002 
Input
7
4 10 22 11 12 5 6

Output
7
4 10 22 11 12 5 6 


-----Note-----

The first example is described in the statements.

In the second example the initial sequence is [1000000000, 1000000000, 1000000000, 1000000000]. After the first operation the sequence is equal to [1000000001, 1000000000, 1000000000]. After the second operation the sequence is [1000000001, 1000000001]. After the third operation the sequence is [1000000002].

In the third example there are no two equal consecutive elements initially, so the sequence does not change.

Difficulty: interview

Starter code:

Solutions:
n=int(input())
a=list(map(int,input().split()))
i=0
b=[]
while i+1<n:
    if a[i]==a[i+1]:
        a[i+1]=a[i]+1
        if len(b)>0:
            a[i]=b.pop()
        else:
            i=i+1
    else:
        b.append(a[i])
        i=i+1
b.append(a[-1])
print(len(b))
print(*b)

n = int(input())
a = list(map(int, input().split()))
b = [0] * n
b[0] = a[0]
j = 1
for i in range(1, n):
    b[j] = a[i]
    while j > 0 and b[j] == b[j - 1]:
        j -= 1
        b[j] += 1
    j += 1
print(j)
for i in range(j):
    print(b[i], end=' ')


n, m = int(input()), 0
b = [int(t) for t in input().split()]
a = []
for i in range(n):
	a.append(b[i])
	while len(a) > 1 and a[-2] == a[-1]:
		del a[-1]
		a[-1] += 1
print(len(a))
print(" ".join([str(t) for t in a]))

n = int(input())
a = [int(x) for x in input().split()]
stack = []
i = 0
x = a[i]
while True:
    if len(stack) == 0:
        stack.append(x)
        i += 1
        if i == n:
            break
        x = a[i]
    else:
        if x == stack[-1]:
            del stack[-1]
            x += 1
        else:
            stack.append(x)
            i += 1
            if i == n:
                break
            x = a[i]
print(len(stack))
print(" ".join([str(x) for x in stack]))



import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

n = mint()
a = []
for i in mints():
	if len(a) > 0 and a[-1] == i:
		a[-1] += 1
		while len(a) > 1 and a[-2] == a[-1]:
			a.pop()
			a[-1] += 1
	else:
		a.append(i)
print(len(a))
print(*a)


 
n=int(input())
x=[int(i) for i in input().split()]
otv=[]
i=0
while i<n:
    if len(otv)<2:
        otv.append(x[i])
        i+=1
        continue
    if otv[len(otv)-1]==otv[len(otv)-2]:
        otv.pop()
        otv[len(otv)-1]+=1
    else:
        otv.append(x[i])
        i+=1
while len(otv)>=2 and otv[len(otv)-1]==otv[len(otv)-2]:
    otv.pop()
    otv[len(otv)-1]+=1
print(len(otv))
for i in otv:
    print(i,end=" ")

        

n, m = int(input()), 0
b = [int(t) for t in input().split()]
a = []
for i in range(n):
	a.append(b[i])
	while len(a) > 1 and a[-2] == a[-1]:
		del a[-1]
		a[-1] += 1
print(len(a))
print(" ".join([str(t) for t in a]))


# https://codeforces.com/problemset/problem/926/E

input()
stack1 = [int(i) for i in input().split()]
stack1.reverse()

stack2 = []

while stack1:
    transfer = stack1.pop()

    while stack2 and stack2[-1] == transfer:
        stack2.pop()
        transfer += 1

    stack2.append(transfer)

print(len(stack2))
print(" ".join([str(i) for i in stack2]))

stk = []
n = input()
n = int(n)
lst = input()
lst = lst.split()

for a in lst:
    stk.append(int(a))
    while len(stk) > 1:
        if stk[-1] == stk[-2]:
            b = stk[-1]
            stk.pop()
            stk.pop()
            stk.append(b + 1)
        else:
            break
print(len(stk))
for a in stk:
    print(a , end=" ")