#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int a[N + 5];
int num[50];
int number[50];
int n;
int main() {
  scanf("%d", &n);
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    bitset<40> b(a[i]);
    for (int j = 0; j < 32; j++) {
      if (b.test(j)) {
        number[j] = a[i];
        num[j]++;
      }
    }
  }
  for (int i = 40; i >= 0; i--) {
    if (num[i] == 1) {
      mx = number[i];
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == mx) swap(a[i], a[1]);
  }
  for (int i = 1; i <= n; i++) printf("%d ", a[i]);
  putchar('\n');
  return 0;
}
