#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6 + 5;
const long long mod = 1e9 + 7;
int main() {
  long long n;
  cin >> n;
  long long a[n + 5], pre[n + 5], suf[n + 5], ans = INT_MIN, ind;
  for (int i = 0; i < n; i++) cin >> a[i];
  pre[0] = ~a[0];
  for (int i = 1; i < n; i++) {
    pre[i] = pre[i - 1] & ~a[i];
  }
  suf[n - 1] = ~a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    suf[i] = suf[i + 1] & ~a[i];
  }
  for (int i = 1; i < n - 1; i++) {
    if ((pre[i - 1] & a[i] & suf[i + 1]) > ans) {
      ans = (pre[i - 1] & a[i] & suf[i + 1]);
      ind = i;
    }
  }
  if ((a[0] & suf[1]) > ans) ind = 0;
  if ((a[n - 1] & pre[n - 2]) > ans) ind = n - 1;
  cout << a[ind] << " ";
  for (int i = 0; i < n; i++) {
    if (i == ind) continue;
    cout << a[i] << " ";
  }
  return 0;
}
