#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 50;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> pref(n), suff(n);
  pref[0] = a[0] ^ LLONG_MAX;
  for (long long i = 1; i < n; i++) {
    pref[i] = pref[i - 1] & (a[i] ^ LLONG_MAX);
  }
  suff[n - 1] = a[n - 1] ^ LLONG_MAX;
  for (long long i = n - 2; i >= 0; i--) {
    suff[i] = suff[i + 1] & (a[i] ^ LLONG_MAX);
  }
  long long ans = 0;
  long long x = -1;
  for (long long i = 0; i < n; i++) {
    long long val = a[i];
    if (i - 1 >= 0) {
      val &= (pref[i - 1]);
    }
    if (i + 1 < n) val &= suff[i + 1];
    if (val >= ans) {
      x = i;
      ans = val;
    }
  }
  cout << a[x] << ' ';
  for (long long i = 0; i < n; i++) {
    if (i != x) cout << a[i] << ' ';
  }
}
