#include <bits/stdc++.h>
using namespace std;
long long n, a[500009], fix[60], x, ans, sum, ind;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    x = 0;
    while ((1 << x) <= a[i]) {
      if (a[i] & (1 << x)) fix[x]++;
      x++;
    }
  }
  ind = 1;
  for (int i = 1; i <= n; i++) {
    sum = 0;
    x = 0;
    while ((1 << x) <= a[i]) {
      if (a[i] & (1 << x)) {
        if (fix[x] == 1) sum += (1 << x);
      }
      x++;
    }
    if (ans < sum) ans = sum, ind = i;
  }
  swap(a[1], a[ind]);
  for (int i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
