import java.util.*;

public class C {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Item[] a = new Item[n];
        for (int i = 0; i < n; i++)
            a[i] = new Item(in.nextInt());

        for (int r = 0; r < 32; r++) {
            int hit = -1;
            for (int i = 0; i < n; i++) {
                int x = 1;
                if (((a[i].key >> r) & 1) == 1) {
                    if (hit == -1) {
                        hit = i;
                    } else {
                        hit = -1;
                        break;
                    }
                }
            }
            if (hit != -1) {
                a[hit].value += 1 << r;
            }
        }
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (a[i].value > a[max].value) {
                max = i;
            }
        }
        if (max != 0) {
            int temp = a[0].key;
            a[0].key = a[max].key;
            a[max].key = temp;
        }
        for (int i = 0; i < n; i++) {
            System.out.print(a[i].key + " ");
        }
    }

    static class Item {
        int key, value;

        Item(int key) {
            this.key = key;
            this.value = 0;
        }
    }
}