#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int MAXN = 0;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int v[n];
  for (int i = 0; i < (n); ++i) cin >> v[i];
  int pref[n], suff[n];
  pref[0] = suff[n - 1] = INT_MAX;
  for (int i = (1); i < (n); ++i) {
    pref[i] = pref[i - 1] & (~v[i - 1]);
  }
  for (int i = (n - 2); i >= (0); --i) {
    suff[i] = suff[i + 1] & (~v[i + 1]);
  }
  int max = INT_MIN;
  int pos = 0;
  int test = 0;
  for (int i = 0; i < (n); ++i) {
    test = pref[i] & suff[i] & v[i];
    if (test > max) {
      max = test;
      pos = i;
    }
  }
  cout << v[pos] << " ";
  for (int i = 0; i < (n); ++i) {
    if (i != pos) cout << v[i] << " ";
  }
}
