#include <bits/stdc++.h>
using namespace std;
void readFile() {}
long long binpow(long long a, long long b) {
  if (b == 0) return 1;
  long long res = binpow(a, b / 2);
  if (b % 2)
    return res * res * a;
  else
    return res * res;
}
int main() {
  readFile();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int bits[30];
  memset(bits, 0, sizeof bits);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 30; j++) {
      if ((1 << j) & arr[i]) bits[j]++;
    }
  }
  int ans{-1};
  int elem;
  for (int i = 0; i < n; i++) {
    int temp = arr[i];
    for (int j = 0; j <= 30; j++) {
      if ((1 << j) & arr[i]) {
        if (bits[j] > 1) temp -= binpow(2, j);
      }
    }
    if (temp > ans) {
      elem = arr[i];
      ans = temp;
    }
  }
  cout << elem << " ";
  bool found = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == elem && !found) {
      found = 1;
    } else
      cout << arr[i] << " ";
  }
  cout << endl;
  return 0;
}
