#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 2e5 + 7;
int a[maxn];
vector<int> num[50];
void f(int x) {
  int p = 0, y = x;
  while (x) {
    p++;
    if (x % 2 == 1) num[p].push_back(y);
    x /= 2;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  reverse(a + 1, a + 1 + n);
  int ans = a[1];
  for (int i = 1; i <= n; i++) f(a[i]);
  for (int i = 40; i >= 1; i--)
    if (num[i].size() == 1) {
      ans = num[i][0];
      break;
    }
  printf("%d", ans);
  int flag = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == ans && flag == 1) {
      flag--;
      continue;
    }
    printf(" %d", a[i]);
  }
  return 0;
}
