import java.util.*;
import java.io.*;
public class R618D2C {
 
	public static void main(String[] args) throws Exception{
		int num = 998244353;
		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		long maxlength = 0;
 		long[] array1 = new long[n];
 		String[] array = new String[n];
 		for(int i = 0;i<n;i++){
 			long a = Long.parseLong(st.nextToken());
 			array1[i] = a;
 			String c = Long.toBinaryString(a);
 			char[] asdf = c.toCharArray();
 			char[] asdfn = new char[asdf.length];
 			for(int j = 0;j<asdf.length;j++)
 			{
 				asdfn[asdf.length-j-1] = asdf[j];
 			}
 			String d = new String(asdfn);
  			if (c.length() > maxlength)
 				maxlength = c.length();
 			array[i] = d;
 
 		}
 		int[] buckets = new int[n];
 		for(int i = 0;i<maxlength;i++)
 		{
 			int count = 0;
 			int index = -1;
 			for(int j = 0;j<n;j++){
 				if (array[j].length() > i && array[j].charAt(i) == '1'){
 					count++;
 					index = j;
 				}
 			}
 			if (count == 1)
 				buckets[index]+=Math.pow(2, i);
 		}
 		int maxindex = -1;
 		long maxnum = 0;
 		for(int i = 0;i<n;i++){
 			if (buckets[i] > maxnum){
 				maxindex = i;
 				maxnum = buckets[i];
 			}
 		}
 		if (maxindex < 0)
 			maxindex = 0;
 		out.print(array1[maxindex] + " ");
 		for(int i = 0;i<n;i++){
 			if (i != maxindex)
 				out.print(array1[i] + " ");
 		}
 		out.println();
 		out.close();
 		
 		
	}
 
}