{"raw_statement":[{"iden":"statement","content":"You are given a sequence of positive integers _a_1, _a_2, ..., _a__n_.\n\nWhile 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.\n\nYou stop performing the operation when there is no pair of equal consecutive elements.\n\nFor 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.\n\nDetermine the final sequence after you stop performing the operation."},{"iden":"input","content":"The first line contains a single integer _n_ (2 ≤ _n_ ≤ 2·105) — the number of elements in the sequence.\n\nThe second line contains the sequence of integers _a_1, _a_2, ..., _a__n_ (1 ≤ _a__i_ ≤ 109)."},{"iden":"output","content":"In the first line print a single integer _k_ — the number of elements in the sequence after you stop performing the operation.\n\nIn the second line print _k_ integers — the sequence after you stop performing the operation."},{"iden":"examples","content":"Input\n\n6\n5 2 1 1 2 2\n\nOutput\n\n2\n5 4 \n\nInput\n\n4\n1000000000 1000000000 1000000000 1000000000\n\nOutput\n\n1\n1000000002 \n\nInput\n\n7\n4 10 22 11 12 5 6\n\nOutput\n\n7\n4 10 22 11 12 5 6"},{"iden":"note","content":"The first example is described in the statements.\n\nIn 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\\].\n\nIn the third example there are no two equal consecutive elements initially, so the sequence does not change."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}