import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		new Mains().main();
	}
}

class Mains{
	public void swap(int [] a , int i , int j) {
		int temp = a[i];
		a[i] = a[j];
		a[j] = temp;
	}
	public void main() {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int [] a = new int[n];
		int [] b = new int[32];
		Arrays.fill(b , 0);
		for(int i = 0; i < n; ++i) {
			a[i] = input.nextInt();
			for(int j = 0; j < 31; ++j) {
				if((a[i] & (1 << j)) != 0) {
					++b[j];
				}
			}
		}
		input.close();
		int maxValue = 0 , index = 0;
		for(int i = 0; i < n; ++i) {
			int value = a[i] , tempValue = 0;
			for(int j = 0; j < 31; ++j) {
				if((value & (1 << j)) != 0 && b[j] == 1) {
					tempValue += (1 << j);
				}
			}
			if(tempValue > maxValue) {
				maxValue = tempValue;
				index = i;
			}
		}
		swap(a , 0 , index);
		
		for(int i = 0; i < n; ++i) {
			System.out.print(a[i]);
			if(i < n - 1) {
				System.out.print(" ");
			}
		}
	}
}