#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  map<int, int> b;
  for (int i = 0; i < n; i++) {
    int x = a[i];
    int j = 0;
    while (x) {
      b[j] += x % 2;
      j++;
      x /= 2;
    }
  }
  int pos = 0;
  int r = 0;
  for (int i = 0; i < n; i++) {
    int cand = 0;
    int x = a[i];
    int j = 0;
    while (x) {
      if (b[j] == 1 && x % 2) cand |= (1 << j);
      j++;
      x /= 2;
    }
    if (cand > r) r = cand, pos = i;
  }
  vector<int> res = {a[pos]};
  for (int i = 0; i < n; i++)
    if (pos != i) res.push_back(a[i]);
  for (auto x : res) cout << x << " ";
  cout << endl;
  return 0;
}
