#include <bits/stdc++.h>
const double eps = 1e-7, PI = 3.1415926;
const int N = 2e5 + 10;
using namespace std;
int n, q, m, k, x, y, a[N], mx = -1, mn = 1e9, sum, t;
char c[N];
string s, s1, s2;
map<int, int> mp;
vector<int> vec;
void f(long long x) {
  vector<int> bit;
  while (x) {
    bit.push_back(x % 2);
    x /= 2;
  }
  int i = 0;
  for (auto X : bit) {
    if (X) mp[i]++;
    i++;
  }
  return;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    f(a[i]);
  }
  for (int i = 32; i >= 0; i--) {
    if (mp[i] == 1) {
      for (int j = 0; j < n; j++) {
        if (a[j] & (1 << i)) {
          y = a[j];
        }
      }
      break;
    }
  }
  if (y) {
    cout << y << " ";
    for (int i = 0; i < n; i++) {
      if (a[i] != y) cout << a[i] << " ";
    }
  } else
    for (int i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
  return 0;
}
