#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<unsigned> a(n);
  for (auto &e : a) {
    cin >> e;
  }
  vector<unsigned> pl(n), pr(n);
  pl[0] = -1;
  for (int i = 0; i + 1 < n; ++i) {
    pl[i + 1] = pl[i] & ~a[i];
  }
  pr[n - 1] = -1;
  for (int i = n - 1; i > 0; --i) {
    pr[i - 1] = pr[i] & ~a[i];
  }
  int imax = 0;
  unsigned vmax = 0;
  for (int i = 0; i < n; ++i) {
    unsigned t = pl[i] & pr[i] & a[i];
    if (t > vmax) {
      imax = i;
      vmax = t;
    }
  }
  cout << a[imax] << ' ';
  for (int i = 0; i < n; ++i) {
    if (i != imax) {
      cout << a[i] << ' ';
    }
  }
  cout << endl;
  return 0;
}
