1 #include <algorithm>
2 #include <iostream>
3 using namespace std;
4
5 int main(){
6 int hash[10000] = { 0 };
7 int x, n, a[110], num = 0;
8 cin >> x;
9 for (int i = 0; i<x; i++){
10 cin >> a[i];
11 n = a[i];
12 if (hash[n] == 1)
13 continue;
14 while (n>1){
15 if (n % 2 == 0)
16 n /= 2;
17 else n = (3 * n + 1) / 2;
18 hash[n] = 1;
19 }
20 }
21 sort(a, a + x);
22 for (int i = x - 1; i >= 0; i--){
23 if (hash[a[i]] == 0){
24 num++;
25 if (num>1) cout << " ";
26 cout << a[i];
27 }
28 }
29 return 0;
30 }