#include <bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) {
      res *= a;
    }
    a *= a;
    n >>= 1;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<vector<long long>> v(n, vector<long long>(32, 0));
  vector<long long> t(n);
  long long a;
  map<long long, long long> m;
  for (long long i = 0; i < n; ++i) {
    cin >> a;
    t[i] = a;
    long long j = 0;
    while (a != 0) {
      v[i][j] = a & 1;
      a >>= 1;
      ++j;
    }
  }
  bool f = false;
  for (long long j = 0; j < 32; ++j) {
    long long c = 0, p;
    for (long long i = 0; i < n; ++i) {
      if (v[i][j]) {
        ++c;
        p = i;
      }
    }
    if (c == 1) {
      f = true;
      m[t[p]] += binpow(2, j);
    }
  }
  if (!f) {
    for (auto x : t) {
      cout << x << " ";
    }
  } else {
    long long mx = 0, mxi;
    for (auto x : m) {
      if (x.second > mx) {
        mx = x.second;
        mxi = x.first;
      }
    }
    cout << mxi << " ";
    for (auto x : t) {
      if (x != mxi) {
        cout << x << " ";
      }
    }
  }
  return 0;
}
