#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  unsigned int n;
  cin >> n;
  vector<unsigned int> a(n + 1), pre(n + 1), suf(n + 1);
  for (unsigned int i = 0; i != n; ++i) cin >> a[i];
  for (unsigned int i = 0; i <= n; ++i) pre[i] = suf[i] = ~a[i];
  for (unsigned int i = 1; i != n; ++i) pre[i] &= pre[i - 1];
  for (unsigned int i = n - 1; i; --i) suf[i] &= suf[i + 1];
  unsigned int ans = 0, max = a[0] & suf[1];
  for (unsigned int i = 1; i != n; ++i)
    if (max < (pre[i - 1] & a[i] & suf[i + 1])) {
      ans = i;
      max = pre[i - 1] & a[i] & suf[i + 1];
    }
  swap(a[0], a[ans]);
  for (unsigned int i = 0; i != n; ++i) cout << a[i] << " \n"[i == n - 1];
}
