#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], de[50];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    int x = a[i];
    for (int j = 0; j < 32; j++)
      if ((x >> j) & 1) de[j]++;
  }
  int mx = 0, pos = 1;
  for (int i = 1; i <= n; i++) {
    int x = a[i];
    for (int j = 0; j < 32; j++)
      if ((x >> j) & 1) de[j]--;
    int now = 0;
    for (int j = 0; j < 32; j++)
      if (de[j]) now |= 1 << j;
    now = a[i] - (a[i] & now);
    if (mx <= now) {
      pos = i;
      mx = now;
    }
    for (int j = 0; j < 32; j++)
      if ((x >> j) & 1) de[j]++;
  }
  printf("%d", a[pos]);
  for (int i = 1; i <= n; i++)
    if (i != pos) printf(" %d", a[i]);
  return 0;
}
