#P1261. Math!!!

Math!!!

题目描述

One day Zsh discovers an interesting problem,For any positive integer xx, if it is even, cut it in half; if it is odd, cut (3x+1)(3x+1) in half. Keep doing again and again, and you must get x=1x=1 at some point. For example,if x=3x = 3,let's do it.

  • 3mod2=13\\ mod\\ 2 = 1,x=3x+1=10x = 3 * x + 1 = 10,x/2=5x / 2 = 5

  • 5mod2=15\\ mod\\ 2 = 1,x=3x+1=16x = 3 * x + 1 = 16,x/2=8x/2=8

  • 8mod2=08\\ mod \\ 2 = 0,x/2=4x /2=4

  • 4mod2=04 \\ mod \\ 2 = 0,x/2=2x/2=2

  • 2mod2=02 \\ mod \\ 2 = 0,x/2=1x/2=1

In the fifth step x=1x = 1,so we can stop.

To avoid double counting, you can record each number visited during the recursion. For example, when verifying n=3n=3, we need to calculate 3,5,8,4,2,13, 5, 8, 4, 2, 1. Then, when we verify n=5,8,4,2n=5, 8, 4, 2, we can directly determine the result of the conjecture without repeating the calculation, because these 4 numbers have already been visited when verify 33, and we call 5,8,45, 8, 4 and 22 the numbers that cover 33. We call a number nn which in a series is a "key number" if and only if nn cannot be covered by any other numbers in the series.

Given a series of numbers to be verified, we only need to verify a few of the key numbers, so that we don't have to repeat the verification for the rest of the numbers. Your task is to find these key numbers and output them in order from the largest to the smallest.

输入格式

he first line contains an integer KK (1leqKleq10001 \\leq K \\leq 1000) .

The second line contains KK integers a1,a2,...,ana_1,a_2,...,a_n (2leqaileq100002 \\leq a_i \\leq 10000) .

输出格式

Output the key numbers in order from the largest to the smallest.

样例

6 
3 5 6 7 8 11
7 6