#include <bits/stdc++.h>
using namespace std;
int a[100001];
int b[100001];
int c[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  b[0] = ~a[0];
  for (int i = 1; i < n; i++) {
    b[i] = b[i - 1] & (~a[i]);
  }
  c[n - 1] = ~a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    c[i] = (c[i + 1]) & (~a[i]);
  }
  int ans = -1;
  int idx = -1;
  for (int i = 0; i < n; i++) {
    int t = a[i];
    if (i - 1 >= 0) {
      t = t & b[i - 1];
    }
    if (i + 1 < n) {
      t = t & c[i + 1];
    }
    if (idx == -1 || ans < t) {
      idx = i;
      ans = t;
    }
  }
  cout << a[idx] << ' ';
  for (int i = 0; i < n; i++) {
    if (i == idx) continue;
    cout << a[i] << ' ';
  }
}
