#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> aa(n);
  bool wasnonul = false;
  for (size_t i = 0; i < n; i++) {
    cin >> aa[i];
    if (aa[i]) wasnonul = true;
  }
  if (!wasnonul) {
    for (int var : aa) cout << var << " ";
    return 0;
  }
  for (int i = 30; i >= 0; i--) {
    set<int> was;
    int c = 0, last;
    for (size_t j = 0; j < aa.size(); j++) {
      if (aa[j] & 1 << i && !was.count(aa[j])) {
        ++c;
        last = j;
        was.emplace(aa[j]);
      }
    }
    if (c == 1) {
      cout << aa[last] << " ";
      aa.erase(aa.begin() + last);
    }
  }
  for (int var : aa) cout << var << " ";
  return 0;
}
