import java.util.*;
import java.io.*;

public class Anu {
	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		Integer[] arr = new Integer[n];
		for(int i = 0; i < n; i++)
			arr[i] = nextInt();
		Arrays.sort(arr, null);
		int[] pre = new int[n + 1];
		int[] suf = new int[n + 1];
		pre[0] = arr[0];
		suf[n - 1] = arr[n - 1];
		for(int i = 1; i < n; i++)
			pre[i] = pre[i - 1] | arr[i];
		for(int i = n - 2; i >= 0; i--)
			suf[i] = suf[i + 1] | arr[i];
		int max = (arr[0] | suf[1]) - suf[1];
		int id = 0;
		for(int i = 1; i < n - 1; i++) {
			if(max < (arr[i] | suf[i + 1] | pre[i - 1]) - (suf[i + 1] | pre[i - 1])) {
				max = (arr[i] | suf[i + 1] | pre[i - 1]) - (suf[i + 1] | pre[i - 1]);
				id = i;
			}
		}
		if(n > 1 && (arr[n - 1] | pre[n - 2]) - pre[n - 2] > max)
			 id = n - 1;
		PrintWriter out = new PrintWriter(System.out);
		out.print(arr[id] + " ");
		for(int i = 0; i < n; i++)
			if(i != id)
				out.print(arr[i] + " ");
		out.println();
		out.close();
	}

	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
}
