#include <bits/stdc++.h>
using namespace std;
long long ex[32];
long long A[100000];
int32_t main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> A[i];
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j <= 30; j++) {
      if (A[i] & (1 << j)) {
        ex[j]++;
      }
    }
  }
  long long x = 0;
  for (long long i = 0; i <= 30; i++) {
    if (ex[i] <= 1) {
      x += (1 << i);
    }
  }
  long long _max = 0;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if ((A[i] & x) >= _max) {
      _max = A[i] & x;
      ans = i;
    }
  }
  swap(A[ans], A[0]);
  for (long long i = 0; i < n; i++) {
    cout << A[i] << ' ';
  }
}
