#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 50;
const int MAXM = 35;
int a[MAXN];
int cnt[MAXM], sum;
int N;
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    sum |= a[i];
    for (int j = 0; j <= 30; j++) {
      if (a[i] & (1 << j)) cnt[j]++;
    }
  }
  int maxn = 0, maxid = 1;
  for (int i = 1; i <= N; i++) {
    int tmp = 0;
    for (int j = 0; j <= 30; j++) {
      if (cnt[j] == 1 && (a[i] & (1 << j))) {
        tmp += (1 << j);
      }
    }
    if (tmp > maxn) {
      maxid = i;
      maxn = tmp;
    }
  }
  swap(a[maxid], a[1]);
  for (int i = 1; i <= N; i++) {
    printf("%d ", a[i]);
  }
  puts("");
  return 0;
}
