#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100500;
int n;
long long L[MAXN], R[MAXN], A[MAXN];
long long comp(long long a) { return ((1LL << 32) - 1) ^ a; }
int main() {
  while (scanf("%d", &n) >= 1) {
    for (int i = (0); i < (int)(n); i++) scanf("%lld", &A[i]);
    L[0] = (1LL << 32) - 1;
    for (int i = (0); i < (int)(n); i++) L[i + 1] = L[i] & comp(A[i]);
    R[n] = (1LL << 32) - 1;
    for (int i = (int)(n - 1); i >= (0); i--) R[i] = R[i + 1] & comp(A[i]);
    int p = -1, ans = -1;
    for (int i = (0); i < (int)(n); i++) {
      long long act = A[i] & L[i] & R[i + 1];
      if (act > ans) {
        ans = act;
        p = i;
      }
    }
    swap(A[0], A[p]);
    for (int i = (0); i < (int)(n); i++) {
      if (i) printf(" ");
      printf("%lld", A[i]);
    }
    puts("");
  }
  return 0;
}
