#include <bits/stdc++.h>
using namespace std;
ifstream f("");
ofstream g("");
map<long long, pair<long long, long long>, greater<long long>> ma;
long long v[100009], a[100009], n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    for (long long p = 1; p <= v[i]; p *= 2)
      if (p & v[i]) ma[p].first++, ma[p].second = i;
  }
  for (auto i : ma)
    if (i.second.first == 1 && !a[i.second.second]) {
      cout << v[i.second.second] << " ", a[i.second.second] = 1;
      break;
    }
  for (int i = 1; i <= n; i++)
    if (!a[i]) cout << v[i] << " ";
  return 0;
}
