#include <bits/stdc++.h>
using namespace std;
long long int func(long long int x, long long int y) {
  long long int res = (x | y) - y;
  return res;
}
int main() {
  long long int n;
  cin >> n;
  vector<long long int> v(n, 0), negV(n, 0);
  for (long long int i = 0; i < (n); i++) {
    cin >> v[i];
  }
  for (long long int i = 0; i < (n); i++) {
    negV[i] = ~v[i];
  }
  vector<long long int> prefix(n, 0);
  prefix[0] = ~0;
  for (long long int i = 1; i < (n); i++) {
    prefix[i] = prefix[i - 1] & negV[i - 1];
  }
  vector<long long int> suffix(n, 0);
  suffix[n - 1] = ~0;
  for (long long int i = n - 2; i >= (0); i--) {
    suffix[i] = suffix[i + 1] & negV[i + 1];
  }
  long long int index = 0, nMax = prefix[0] & suffix[0] & v[0];
  for (long long int i = 1; i < (n); i++) {
    long long int res = prefix[i] & suffix[i] & v[i];
    if (res > nMax) {
      nMax = res;
      index = i;
    }
  }
  cout << v[index] << " ";
  for (long long int i = 0; i < (n); i++) {
    if (i == index) continue;
    cout << v[i] << " ";
  }
  return 0;
}
