def main(): n = input() num_str = input().split(' ') res={} result =[] for i in num_str: if(int(i) not in res.keys()): res[int(i)] = 0 for i in num_str: i = int(i) while i !=1: if(i%2==0): i = i/2 else: i = (3*i+1)/2 if(i in res.keys()): res[i] = 1 for i in res: if(res[i] == 0): result.append(i) result.sort(reverse=True) for i ,value in enumerate(result): if(i!=0): print(" ",end='') print(value,end='')main()复制代码