import java.util.*;
import java.io.*;
public class Main {
public static void main(String arg[])throws IOException{
Reader.init(System.in);
PrintStream out=new PrintStream(System.out);
int k=Reader.nextInt();
int sr[]=new int[k];
boolean pd[]=new boolean[150];
int i,j,n=0;
for(i=0;i<k;i++) sr[i]=Reader.nextInt();
for(i=0;i<150;i++) pd[i]=false;
i=0;
while(i!=k)
{
if(pd[sr[i]]==false){
j=sr[i];
while(pd[1]==false)
{
if(j%2==0) j=j/2;
else j=(3*j+1)/2;
pd[j]=true;
}
pd[1]=false;
}
i++;
}
for(i=0;i<k;i++)//递减排序
{
for(n=i+1;n<k;n++){
if(sr[i]<sr[n]){
int temp;
temp=sr[i];
sr[i]=sr[n];
sr[n]=temp;
}
}
}
for(i=0,n=0;i<k;i++) if(pd[sr[i]]==false) n++;
for(i=0;i<k;i++){
if(pd[sr[i]]==false){
out.print(sr[i]);
if(n!=1) out.print(" ");
out.flush();
n--;
}
}//保证末尾无空格
}
public static class Reader{
static BufferedReader reader;
static StringTokenizer tokenizer;
static void init(InputStream input){
reader=new BufferedReader(new InputStreamReader(input));
tokenizer=new StringTokenizer("");
}
static String next() throws IOException{
while(!tokenizer.hasMoreTokens()){
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
static int nextInt()throws IOException{
return Integer.parseInt(next());
}
static double nextDouble() throws IOException{
return Double.parseDouble(next());
}
}
}
qq_遁去的一_1
相关分类