#include <bits/stdc++.h>
using namespace std;
int a[100005], f[35];
int main() {
  ios::sync_with_stdio(false);
  int k = 0, n, ans = -1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 0; j < 31; j++)
      if (a[i] & 1 << j) f[j]++;
  }
  for (int i = 1; i <= n; i++) {
    int num = 0;
    for (int j = 0; j < 31; j++) {
      if (a[i] & 1 << j) f[j]--;
      if (f[j]) num |= 1 << j;
    }
    if (ans < (a[i] | num) - num) {
      ans = (a[i] | num) - num;
      k = i;
    }
    for (int j = 0; j < 31; j++)
      if (a[i] & 1 << j) f[j]++;
  }
  cout << a[k] << ' ';
  for (int i = 1; i <= n; i++)
    if (i != k) cout << a[i] << ' ';
  cout << endl;
  return 0;
}
