#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
stringstream output;
inline void eOP();
inline void solve() {
  int n;
  cin >> n;
  unordered_map<int, int> cnt;
  vector<int> a(n);
  for (int& e : a) {
    cin >> e;
    int i = 1;
    while (i <= e) {
      cnt[i] += !!(i & e);
      i <<= 1;
    }
  }
  int m = 0;
  for (int i = 1; cnt.count(i); i <<= 1) {
    if (cnt[i] == 1) {
      m |= i;
    }
  }
  int b;
  int mx = -1;
  for (int i = 0; i < n; ++i) {
    int e = a[i];
    int d = m & e;
    if (d > mx) {
      mx = d;
      b = i;
    }
  }
  swap(a[0], a[b]);
  for (int e : a) {
    cout << e << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  size_t t = 1;
  for (int i = 0; i < t; ++i) {
    solve();
  }
  eOP();
}
inline void eOP() {
  cout << output.str();
  output.str(string());
  exit(0);
}
