#include <bits/stdc++.h>
using namespace std;
int suf[100005];
int num[100005];
int pre[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> num[i];
  }
  pre[1] = ~num[1];
  for (int i = 2; i <= n; i++) {
    pre[i] = pre[i - 1] & (~num[i]);
  }
  suf[n] = ~num[n];
  for (int i = n - 1; i >= 1; i--) {
    suf[i] = suf[i + 1] & (~num[i]);
  }
  int m = num[1] & (suf[2]);
  int pos = 1;
  for (int i = 2; i <= n; i++) {
    if (i == n) {
      if ((num[n] & pre[n - 1]) > m) {
        pos = i;
      }
      break;
    }
    if ((num[i] & pre[i - 1] & suf[i + 1]) > m) {
      m = num[i] & pre[i - 1] & suf[i + 1];
      pos = i;
    }
  }
  swap(num[1], num[pos]);
  for (int i = 1; i <= n; i++) {
    cout << num[i] << " ";
  }
}
