#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2) {
      res = res * a;
      b--;
    } else {
      a = a * a;
      b /= 2;
    }
  }
  return res;
}
void func() {
  int n;
  cin >> n;
  long long arr[n];
  for (int insert = 0; insert < n; insert++) {
    cin >> arr[insert];
  }
  int pre[n];
  int suff[n];
  pre[0] = (~arr[0]);
  suff[n - 1] = (~arr[n - 1]);
  for (int insert = 1; insert < n; insert++) {
    pre[insert] = ((~arr[insert]) & pre[insert - 1]);
  }
  for (int insert = n - 2; insert >= 0; insert--)
    suff[insert] = ((~arr[insert]) & suff[insert + 1]);
  long long maxi = arr[0] & suff[1];
  long long pos = 0;
  for (int insert = 1; insert <= n - 2; insert++) {
    if (maxi < ((pre[insert - 1] & suff[insert + 1]) & arr[insert])) {
      maxi = pre[insert - 1] & suff[insert + 1] & arr[insert];
      pos = insert;
    }
  }
  if (maxi < (pre[n - 2] & arr[n - 1])) {
    pos = n - 1;
  }
  cout << arr[pos] << " ";
  for (int insert = 0; insert < n; insert++) {
    if (pos != insert) cout << arr[insert] << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  func();
  return 0;
}
