#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, i;
  cin >> n;
  int a[n], b[n], c[n];
  vector<pair<int, int> > v;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = (~a[i]);
    c[i] = b[i];
  }
  for (i = 1; i < n; i++) {
    b[i] = b[i] & b[i - 1];
  }
  for (i = n - 2; i >= 0; i--) {
    c[i] = c[i] & c[i + 1];
  }
  int maxs = 0, ans, tmp;
  for (i = 0; i < n; i++) {
    if (i > 0) {
      if (i < n - 1) {
        tmp = a[i] & c[i + 1] & b[i - 1];
      } else {
        tmp = a[i] & b[i - 1];
      }
    } else {
      tmp = a[i] & c[i + 1];
    }
    if (tmp >= maxs) {
      maxs = tmp;
      ans = i;
    }
  }
  cout << a[ans] << " ";
  for (i = 0; i < n; i++) {
    if (i != ans) {
      cout << a[i] << " ";
    }
  }
}
