#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> l(n), r(n);
  l[0] = ~a[0];
  r[n - 1] = ~a[n - 1];
  for (int i = 1; i < n; i++) {
    l[i] = l[i - 1] & (~a[i]);
  }
  for (int i = n - 2; i > 0; i--) {
    r[i] = r[i + 1] & (~a[i]);
  }
  int ans = INT_MIN, id;
  for (int i = 0; i < n; i++) {
    int t = a[i];
    if (i > 0) {
      t &= l[i - 1];
    }
    if (i < n - 1) {
      t &= r[i + 1];
    }
    if (t > ans) {
      ans = t;
      id = i;
    }
  }
  cout << a[id] << " ";
  for (int i = 0; i < n; i++) {
    if (i != id) cout << a[i] << " ";
  }
}
