key中放关键数字,notkey中放非关键数字
n = int(input())
i=0
key = []
notkey = []
nums = input()
for num in nums.split():
num=int(num)
if num not in notkey:
key.append(num)
else:
continue
while True:
if(num%2==0):
num/=2
else:
num=(3*num+1)/2
if num==1:
break
if num not in notkey:
notkey.append(num)
if num in key:
key.remove(num)
key.sort(reverse=True)
i=0
print(key[0],end='')
i+=1
while i<len(key):
print(' '+str(key[i]),end='')
i+=1