#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  int n;
  cin >> n;
  vector<int> z(n), zc(n + 2);
  zc[0] = zc[n + 1] = (1 << 30) - 1;
  cerr << (int64_t)(zc[0] - 1e9);
  for (int i = 0; i < n; i++) {
    cin >> z[i];
    zc[i + 1] = ~z[i];
  }
  vector<int> pref(n + 2), suf(n + 2);
  pref[0] = pref[n + 1] = suf[0] = suf[n + 1] = zc[0];
  for (int i = 1; i <= n; i++) {
    pref[i] = pref[i - 1] & zc[i];
    suf[n - i + 1] = suf[n - i + 2] & zc[n - i + 1];
  }
  int idx = 0, mx = -1;
  for (int i = 1; i <= n; i++) {
    if (mx < ((z[i - 1] & pref[i - 1]) & suf[i + 1])) {
      mx = ((z[i - 1] & pref[i - 1]) & suf[i + 1]);
      idx = i - 1;
    }
  }
  cout << z[idx] << " ";
  for (int i = 0; i < n; i++) {
    if (i == idx) {
      continue;
    }
    cout << z[i] << " ";
  }
}
