import javax.swing.*;
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class C
{
    /*
     * This FastReader code is taken from GeeksForGeeks.com
     * https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
     *
     * The article was written by Rishabh Mahrsee
     */
    public static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static FastReader in = new FastReader();
    public static PrintWriter out = new PrintWriter(System.out);
    public static final int MOD = (int)1e9 + 7;

    public static void main(String[] args)
    {
        int n = in.nextInt();
        int[] arr = new int[n];
        int[] pref = new int[n];
        int[] suff = new int[n];

        for (int i = 0; i < n; i++)
            arr[i] = in.nextInt();

        pref[0] = ~arr[0];
        suff[n - 1] = ~arr[n - 1];

        for (int i = 1; i < n; i++)
        {
            pref[i] = ~arr[i] & pref[i - 1];
        }

        for (int i = n - 2; i >= 0; i--)
        {
            suff[i] = ~arr[i] & suff[i + 1];
        }

        int maxIndex = -1;
        int max = Integer.MIN_VALUE;

        for (int i = 0; i < n; i++)
        {
            int cur = (i - 1 >= 0 ? pref[i - 1] : ~0) & (i + 1 < n ? suff[i + 1] : ~0) & arr[i];

            if (cur > max)
            {
                max = cur;
                maxIndex = i;
            }
        }

        swap(arr, 0, maxIndex);

        for (int i : arr) out.print(i + " ");

        out.println();
        out.close();
    }

    private static void swap(int[] arr, int a, int b)
    {
        int temp = arr[a];
        arr[a] = arr[b];
        arr[b] = temp;
    }

}
