#include <bits/stdc++.h>
using namespace std;
long opposite(long x) { return 1073741823 - x; }
int main() {
  long n;
  cin >> n;
  long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long prefix[n];
  long suffix[n];
  prefix[0] = opposite(a[0]);
  for (int i = 1; i < n; i++) prefix[i] = prefix[i - 1] & opposite(a[i]);
  suffix[n - 1] = opposite(a[n - 1]);
  for (int i = n - 1; i > 0; i--)
    suffix[i - 1] = suffix[i] & opposite(a[i - 1]);
  long max = a[0] & suffix[1];
  long pos = 0;
  for (int i = 1; i < n - 1; i++)
    if (max < (a[i] & suffix[i + 1] & prefix[i - 1])) {
      max = a[i] & suffix[i + 1] & prefix[i - 1];
      pos = i;
    }
  if (max < (a[n - 1] & prefix[n - 2])) {
    max = a[n - 1] & prefix[n - 2];
    pos = n - 1;
  }
  cout << a[pos] << " ";
  for (int i = 0; i < n; i++)
    if (i != pos) cout << a[i] << " ";
  cout << '\n';
}
