#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 32; i >= 1; i--) {
    int tag = 0, tmp;
    for (int j = 1; j <= n; j++) {
      if ((a[j] >> (i - 1)) & 1 == 1 && b[j] == 0) {
        tmp = j;
        if (tag == 1) {
          tag = 0;
          break;
        }
        tag = 1;
      }
    }
    if (tag == 1) {
      printf("%d ", a[tmp]);
      b[tmp] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (b[i] == 0) {
      printf("%d ", a[i]);
    }
  }
  printf("\n");
  return 0;
}
