#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int> b(n + 1), c(n + 1);
  b[0] = c[n] = -1;
  for (int i = 0; i < n; ++i) b[i + 1] = b[i] & ~a[i];
  for (int i = n; i-- > 0;) c[i] = c[i + 1] & ~a[i];
  int x = -1, y = -1;
  for (int i = 0; i < n; ++i) {
    int z = a[i] & b[i] & c[i + 1];
    if (z > x) {
      x = z;
      y = i;
    }
  }
  cout << a[y];
  for (int i = 0; i < n; ++i)
    if (i != y) cout << ' ' << a[i];
  cout << '\n';
  return 0;
}
