#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int arr[n];
  int pref[n];
  int suff[n];
  for (int i = 0; i < n; ++i) cin >> arr[i];
  if (n == 1) {
    cout << arr[0] << endl;
    return;
  }
  pref[0] = (~arr[0]);
  suff[n - 1] = (~arr[n - 1]);
  for (int i = 1; i < n; ++i) pref[i] = pref[i - 1] & (~arr[i]);
  for (int i = n - 2; i >= 0; --i) suff[i] = suff[i + 1] & (~arr[i]);
  int mx = INT_MIN;
  int id = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    if (i == 0) {
      x = suff[1] & arr[i];
    } else if (i == n - 1) {
      x = pref[n - 2] & arr[i];
    } else {
      x = pref[i - 1] & suff[i + 1] & arr[i];
    }
    if (x > mx) {
      id = i;
      mx = x;
    }
  }
  cout << arr[id] << " ";
  for (int i = 0; i < n; ++i) {
    if (i != id) cout << arr[i] << " ";
  }
  cout << endl;
}
int main() { solve(); }
