#include <bits/stdc++.h>
using namespace std;
int a[100004], d[32];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int j = 0; j < n; j++) {
    int x = a[j];
    for (int i = 0; x > 0; i++) {
      d[i] += x % 2;
      x /= 2;
    }
  }
  int p = 1, e = 0;
  for (int i = 0; i < 32; i++) {
    if (d[i] == 1) {
      e += p;
    }
    p *= 2;
  }
  int c = -1, m = 0;
  for (int i = 0; i < n; i++) {
    int x = a[i] & e;
    if (x > m) {
      m = x;
      c = i;
    }
  }
  if (c != -1) {
    cout << a[c] << " ";
  }
  for (int j = 0; j < n; j++) {
    if (c != j) cout << a[j] << " ";
  }
  return 0;
}
