#include <bits/stdc++.h>
using namespace std;
long long int n, m, k, g, mx, mn, res, c, x, y, z, w, p, q, r, l, s, t;
long long int cumL[3 * 100000], cumR[3 * 100000];
void solve() {
  cin >> n;
  vector<long long int> a(n + 1);
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  for (long long int i = 1; i < n + 1; i++) cumL[i] = (cumL[i - 1] | a[i]);
  for (long long int i = n; i >= 1; i--) cumR[i] = (cumR[i + 1] | a[i]);
  mx = -1;
  p = 0;
  for (long long int i = 1; i < n + 1; i++) {
    x = cumL[i - 1] | cumR[i + 1];
    if ((a[i] | x) - x > mx) {
      mx = (a[i] | x) - x;
      p = i;
    }
  }
  swap(a[1], a[p]);
  for (long long int i = 1; i < n + 1; i++) cout << a[i] << ' ';
  cout << endl;
}
int main() {
  auto start_time = clock();
  cerr << setprecision(3) << fixed;
  cout << setprecision(10) << fixed;
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  t = 1;
  for (long long int ca = 0; ca < t; ca++) {
    solve();
  }
  auto end_time = clock();
  cerr << "Execution time: "
       << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
}
