#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int q = 1;
  while (q--) {
    long long int n, i, t, j, k = 0, maxm = 0, ans;
    cin >> n;
    vector<long long int> v(n), v1(30), v2;
    map<long long int, long long int> m;
    for (long long int i = 0; i < 30; i++) v1[i] = 0;
    for (long long int i = 0; i < n; i++) {
      cin >> v[i];
      t = v[i];
      j = 0;
      while (t > 0) {
        v1[j] = v1[j] + t % 2;
        t = t / 2;
        j++;
      }
    }
    sort(v.begin(), v.end());
    for (long long int i = 0; i < 30; i++) {
      if (v1[i] == 1) v2.push_back(i);
    }
    if (v2.size() == 0) {
      for (i = n - 1; i >= 0; i--) cout << v[i] << " ";
      return 0;
    }
    for (long long int i = 0; i < n; i++) {
      t = v[i];
      j = 0;
      k = 0;
      while (t > 0) {
        if (j == v2[k]) {
          if (t % 2 != 0) m[v[i]] += pow(2, j);
          k++;
        }
        t = t / 2;
        j++;
      }
    }
    for (auto it = m.begin(); it != m.end(); it++) {
      if ((it->second) > maxm) {
        maxm = it->second;
        ans = it->first;
      }
    }
    cout << ans << " ";
    for (long long int i = 0; i < n; i++) {
      if (v[i] == ans)
        continue;
      else
        cout << v[i] << " ";
    }
  }
}
