#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int cnt[33];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    for (int b = 30; b >= 0; b--) {
      if ((a[i] >> b) & 1) {
        cnt[b]++;
      }
    }
  }
  int bst_b = 30;
  while (bst_b >= 0 && cnt[bst_b] != 1) {
    bst_b--;
  }
  if (bst_b != -1) {
    for (int i = 1; i <= n; i++) {
      if ((a[i] >> bst_b) & 1) {
        swap(a[i], a[1]);
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", a[i]);
  }
  return 0;
}
