#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
long long power(long long a, long long b, long long c) {
  long long res = 1;
  while (b) {
    if (b & 1LL) res = (res * a) % c;
    a = (a * a) % c;
    b /= 2;
  }
  return res;
}
const int N = 1e5 + 5;
int n, a[N], pre[N], suf[N];
void solve() {
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  pre[0] = 0;
  for (i = 1; i <= n; i++) pre[i] = pre[i - 1] | a[i];
  suf[n + 1] = 0;
  for (i = n; i >= 1; i--) suf[i] = suf[i + 1] | a[i];
  int index = 0, ans = -1;
  for (i = 1; i <= n; i++) {
    int temp = (a[i] & ~(pre[i - 1] | suf[i + 1]));
    if (temp > ans) {
      ans = temp;
      index = i;
    }
  }
  cout << a[index] << " ";
  for (i = 1; i <= n; i++) {
    if (i != index) cout << a[i] << " ";
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) solve();
  return 0;
}
