#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], f[N];
int n;
inline int to(int x) {
  int j = 0, Bit = 0;
  while (x) {
    if (x & 1 && f[j] == 1) Bit += (1 << j);
    x >>= 1;
    ++j;
  }
  return Bit;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    int Bit = a[i], j = 0;
    while (Bit) {
      if (Bit & 1) f[j]++;
      j++;
      Bit >>= 1;
    }
  }
  int maxx = -1000, Bit = 0;
  for (int i = 1; i <= n; i++) {
    int j = to(a[i]);
    if (j > maxx) maxx = j, Bit = i;
  }
  printf("%d ", a[Bit]);
  for (int i = 1; i <= n; i++)
    if (i != Bit) printf("%d ", a[i]);
  return 0;
}
