#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  while (test--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long ans = 0;
    long long x = 1;
    vector<pair<long long, long long> > y;
    for (long long j = 0; j < 32; j++) {
      long long cnt = 0;
      long long ptr;
      for (long long i = 0; i < n; i++) {
        if (x & a[i]) cnt++, ptr = i;
      }
      if (cnt == 1) {
        y.push_back({x, ptr});
      }
      x *= 2;
    }
    if (!y.size()) {
      for (long long i = 0; i < n; i++) cout << a[i] << " ";
      cout << "\n";
    } else {
      sort(y.begin(), y.end());
      cout << a[y[y.size() - 1].second] << " ";
      for (long long i = 0; i < n; i++) {
        if (i != y[y.size() - 1].second) cout << a[i] << " ";
      }
      cout << "\n";
    }
  }
}
