#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  vector<long long> v(n, 0), vec;
  vector<bool> vis(n, false);
  for (long long i = 0; i < n; i++) cin >> v[i];
  for (long long mask = 30; mask >= 0; mask--) {
    vec.clear();
    for (long long i = 0; i < n; i++) {
      if ((1 << mask) & v[i]) vec.push_back(i);
    }
    if (vec.size() == 1 and !vis[vec[0]]) {
      cout << v[vec[0]] << " ";
      vis[vec[0]] = true;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (!vis[i]) cout << v[i] << " ";
  }
}
