#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
int N, a[MAX_N], suf[MAX_N], pre[MAX_N];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", a + i);
  for (int i = 1; i <= N; i++) pre[i] = pre[i - 1] | a[i];
  for (int i = N; i; i--) suf[i] = suf[i + 1] | a[i];
  int ans = -1, pos = 0;
  for (int i = 1; i <= N; i++) {
    int cur = a[i] - (a[i] & (pre[i - 1] | suf[i + 1]));
    if (cur > ans) ans = cur, pos = i;
  }
  printf("%d ", a[pos]);
  for (int i = 1; i <= N; i++)
    if (i != pos) printf("%d ", a[i]);
  putchar('\n');
  return 0;
}
