#include <bits/stdc++.h>
using namespace std;
long long data[(int)1e5 + 5];
long long cnt[40];
bool cmp(long long x, long long y) { return x > y; }
int main() {
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> data[i];
  for (int i = 0; i < n; i++) {
    for (long long j = 0; j <= 33; j++) {
      if (data[i] & (1ll << j)) cnt[j]++;
    }
  }
  bool flag = 0;
  int top = 0;
  sort(data, data + n, cmp);
  for (int i = 33; i >= 0; i--) {
    for (int j = 0; j < n; j++) {
      if ((data[j] & (1ll << i)) && cnt[i] == 1) {
        top = j;
        flag = 1;
        break;
      }
    }
    if (flag) break;
  }
  cout << data[top] << " ";
  for (int i = 0; i < n; i++) {
    if (i == top) continue;
    cout << data[i] << " ";
  }
}
