#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int num[100];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    for (int j = 0; j <= 30; j++) {
      if ((a[i] >> j) & 1) num[j]++;
    }
  }
  int tmp = 0;
  for (int i = 0; i <= 30; i++) {
    if (num[i] == 1) {
      tmp ^= (1 << i);
    }
  }
  int ans = 0, pos = 1;
  for (int i = 1; i <= n; i++) {
    if ((a[i] & tmp) > ans) {
      ans = (a[i] & tmp);
      pos = i;
    }
  }
  swap(a[1], a[pos]);
  for (int i = 1; i <= n; i++) printf("%d ", a[i]);
}
