#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> orepre(n), oresuf(n);
  int ore = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    ore |= a[i];
    orepre[i] = ore;
  }
  ore = 0;
  for (int i = n - 1; i >= 0; i--) {
    ore |= a[i];
    oresuf[i] = ore;
  }
  int maxi = -1, id = 0;
  for (int i = 0; i < n; i++) {
    int ans;
    if (i == 0) {
      ans = a[i] - (a[i] & oresuf[i + 1]);
    } else if (i == n - 1) {
      ans = a[i] - (a[i] & orepre[i - 1]);
    } else {
      ans = a[i] - (a[i] & (orepre[i - 1] | oresuf[i + 1]));
    }
    if (maxi < ans) {
      maxi = ans;
      id = i;
    }
  }
  cout << a[id] << " ";
  for (int i = 0; i < n; i++) {
    if (id == i) continue;
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}
