#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3;
int a[N], b[N];
int main() {
  int n, x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 31; i >= 0; i--) {
    int id = 0, vis = 0;
    for (int j = 1; j <= n; j++) {
      if (a[j] >> i & 1 == 1 && b[j] == 0) {
        id = j;
        if (vis == 1) {
          vis = 0;
          break;
        }
        vis++;
      }
    }
    if (vis == 1) {
      printf("%d ", a[id]);
      b[id] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (b[i] != 1) printf("%d ", a[i]);
  }
  return 0;
}
