#include <bits/stdc++.h>
using namespace std;
int bourrin(vector<long long> &v) {
  int res = 0;
  sort(v.begin(), v.end());
  vector<long long> best(v.size());
  do {
    int current = v[0];
    for (int c = 1; c < v.size(); c++) {
      current |= v[c];
      current -= v[c];
    }
    if (current > res) {
      res = current;
      copy(v.begin(), v.end(), best.begin());
    }
  } while (next_permutation(v.begin(), v.end()));
  for (int c = 0; c < best.size(); c++) cout << best[c] << " ";
  cout << endl;
  return res;
}
long long naive(vector<long long> &v) {
  vector<bool> done(v.size(), false);
  long long pow2 = 1;
  long long maxi = *max_element(v.begin(), v.end());
  while (pow2 < maxi) pow2 *= 2;
  int i = 0;
  while (pow2 != 0) {
    int found = 0;
    int idx = 0;
    for (int c = 0; c < v.size(); c++) {
      if (v[c] & pow2) {
        idx = c;
        found++;
      }
    }
    pow2 /= 2;
    if (done[idx]) continue;
    if (found != 1) continue;
    done[idx] = true;
    cout << v[idx] << " ";
  }
  for (int c = 0; c < v.size(); c++) {
    if (!done[c]) cout << v[c] << " ";
  }
  int current = 0;
  return current;
}
int main() {
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long> v(N);
  for (int c = 0; c < N; c++) cin >> v[c];
  naive(v);
}
