#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int INF = int(1e9 + 1);
const int mod = 998244353;
const long double eps = 0.00001;
void Go() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int n;
vector<long long> mas;
vector<int> u(60, 0);
void input() {
  cin >> n;
  mas.resize(n);
  for (auto& i : mas) {
    cin >> i;
    for (int j = 0; j < 60; ++j) {
      if ((1ll << j) & i) u[j]++;
    }
  }
}
void solve() {
  long long ans = 0, ind = 0;
  for (int i = 0; i < n; ++i) {
    long long kol = 0;
    for (int j = 0; j < 60; ++j) {
      int c = u[j];
      if (c == 1 && ((1ll << j) & mas[i])) kol += (1ll << j);
    }
    if (kol >= ans) ans = kol, ind = i;
  }
  cout << mas[ind] << ' ';
  for (int i = 0; i < n; ++i) {
    if (i != ind) cout << mas[i] << ' ';
  }
}
signed main() {
  Go();
  int Q = 1;
  while (Q--) {
    input();
    solve();
  }
}
