#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, x, j;
  cin >> n;
  long long int e[30];
  e[0] = 1;
  for (i = 1; i < 30; i++) e[i] = 2 * e[i - 1];
  long long int c[n], arr[n][30], bit[30] = {0};
  for (i = 0; i < n; i++)
    for (j = 0; j < 30; j++) arr[i][j] = 0;
  for (i = 0; i < n; i++) {
    cin >> x;
    j = 0;
    c[i] = x;
    while (x) {
      if (x % 2) {
        ++bit[j], ++arr[i][j];
      }
      ++j;
      x = x / 2;
    }
  }
  long long int max = -1, maxindex = -1;
  for (i = 0; i < n; i++) {
    long long int ans = 0;
    for (j = 0; j < 30; j++) {
      if (bit[j] <= 1) ans = ans + arr[i][j] * e[j];
    }
    if (ans > max) {
      max = ans;
      maxindex = i;
    }
  }
  cout << c[maxindex] << " ";
  for (i = 0; i < n; i++)
    if (i != maxindex) cout << c[i] << " ";
  cout << "\n";
  return 0;
}
