#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long MOD = 998244353;
const long long inf = 1e18;
const long long MAX = 2e5 + 1;
inline long long add(long long a, long long b) {
  return ((a % mod) + (b % mod)) % mod;
}
inline long long sub(long long a, long long b) {
  return ((a % mod) - (b % mod) + mod) % mod;
}
inline long long mul(long long a, long long b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long pwr(long long x, long long n) {
  x = x % mod;
  if (!n) return 1;
  if (n & 1)
    return mul(x, pwr(mul(x, x), (n - 1) / 2));
  else
    return pwr(mul(x, x), n / 2);
}
long long modinv(long long n) { return pwr(n, mod - 2); }
long long inv(long long i) {
  if (i == 1) return 1;
  return (MOD - (MOD / i) * inv(MOD % i) % MOD) % MOD;
}
bool f(int a, int b) { return a > b; }
struct cmp {
  bool operator()(const int &k1, const int &k2) { return k1 > k2; }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  while (tt--) {
    int n;
    cin >> n;
    vector<int> v(n, 0), pref(n, 0), suf(n, 0);
    for (long long i = 0; i < n; i++) cin >> v[i];
    pref[0] = INT_MAX;
    suf[n - 1] = INT_MAX;
    for (int i = 1; i < n; i++) pref[i] = pref[i - 1] & (~v[i - 1]);
    for (int i = n - 2; i >= 0; i--) suf[i] = suf[i + 1] & (~v[i + 1]);
    int ans = INT_MIN, index;
    for (long long i = 0; i < n; i++) {
      int val = pref[i] & v[i] & suf[i];
      if (val > ans) {
        index = i;
        ans = val;
      }
    }
    cout << v[index] << " ";
    for (long long i = 0; i < n; i++)
      if (i != index) cout << v[i] << " ";
  }
  return 0;
}
