#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, maxn = 1e5 + 2;
int a[maxn], pre[maxn], suf[maxn];
int main() {
  int n, m, ans = -1, pos = 0, t;
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pre[i] = pre[i - 1] | a[i];
  }
  for (register int i = n; i > 0; i--) suf[i] = suf[i + 1] | a[i];
  for (register int i = 1; i <= n; i++) {
    t = pre[i - 1] | suf[i + 1];
    if ((a[i] | t) - t > ans) {
      ans = (a[i] | t) - t;
      pos = i;
    }
  }
  printf("%d ", a[pos]);
  for (register int i = 1; i <= n; i++)
    if (i != pos) printf("%d ", a[i]);
  return 0;
}
