#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int nums[n];
  int sum[32] = {0};
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
    for (int j = 0; j < 32; j++) {
      if (nums[i] & (1 << j)) sum[j]++;
    }
  }
  set<int> one;
  for (int i = 31; i >= 0; i--) {
    if (sum[i] == 1) one.insert(i);
  }
  if (one.size() == 0)
    for (int i = 0; i < n; i++) cout << nums[i] << ' ';
  else {
    pair<int, int> best = make_pair(0, 0);
    for (int i = 0; i < n; i++) {
      int s = 0;
      for (set<int>::iterator j = one.begin(); j != one.end(); j++) {
        if (nums[i] & (1 << (*j))) {
          s += (1 << (*j));
        }
      }
      if (s > best.first) best = make_pair(s, nums[i]);
    }
    cout << best.second << " ";
    for (int i = 0; i < n; i++)
      if (nums[i] != best.second) cout << nums[i] << ' ';
  }
  cout << endl;
  return 0;
}
