#include <bits/stdc++.h>
using namespace std;
const int M = 200001;
int n, m, k, a[M], T;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int t = 30; t >= 0; t--) {
    int sz = 0, fr = 0;
    for (int i = 1; i <= n; i++)
      if ((1 << t) & a[i]) sz++, fr = i;
    if (sz > 1 || !sz) continue;
    printf("%d ", a[fr]);
    for (int i = 1; i <= n; i++)
      if (i != fr) printf("%d ", a[i]);
    return 0;
  }
  for (int i = 1; i <= n; i++) printf("%d ", a[i]);
}
