#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int inputs[100005];
int f[100005];
int b[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &inputs[i]);
  }
  for (int i = 1; i <= n; i++) {
    f[i] = (f[i - 1] | inputs[i]);
  }
  for (int i = n; i >= 1; i--) {
    b[i] = (b[i + 1] | inputs[i]);
  }
  int ans = -1;
  int pos = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = 0;
    int mm = (f[i - 1] | b[i + 1]);
    for (int j = 0; j <= 30; j++) {
      if ((inputs[i] & (1 << j)) && !(mm & (1 << j))) tmp += (1 << j);
    }
    if (tmp > ans) {
      ans = tmp;
      pos = i;
    }
  }
  printf("%d ", inputs[pos]);
  for (int i = 1; i <= n; i++) {
    if (i == pos) continue;
    printf("%d ", inputs[i]);
  }
  printf("\n");
  return 0;
}
