#include <bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
int c[100005];
int main() {
  int n, i, j = 1, k;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  b[0] = c[n + 1] = 2147483647;
  for (i = 1; i <= n; i++) b[i] = b[i - 1] & (~a[i]);
  for (i = n; i >= 1; i--) c[i] = c[i + 1] & (~a[i]);
  int ans = 0;
  for (i = 1; i <= n; i++) {
    if ((b[i - 1] & c[i + 1] & a[i]) > (b[j - 1] & c[j + 1] & a[j])) j = i;
  }
  cout << a[j] << " ";
  for (i = 1; i <= n; i++) {
    if (i != j) cout << a[i] << " ";
  }
  return 0;
}
