#include <bits/stdc++.h>
using namespace std;
int n, a[100010], l[100010], r[100010], maxi, pos, o, ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[1];
    return 0;
  }
  l[1] = a[1];
  for (int i = 2; i <= n; i++) l[i] = (l[i - 1] | a[i]);
  r[n] = a[n];
  for (int i = n - 1; i >= 1; i--) r[i] = (r[i + 1] | a[i]);
  for (int i = 1; i <= n; i++) {
    o = (l[i - 1] | r[i + 1]);
    ans = a[i] - (a[i] & o);
    if (ans >= maxi) {
      maxi = ans;
      pos = i;
    }
  }
  cout << a[pos] << " ";
  for (int i = 1; i <= n; i++) {
    if (i == pos) continue;
    cout << a[i] << " ";
  }
  return 0;
}
