#include <bits/stdc++.h>
using namespace std;
int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979323846;
const int mod = 998244353;
const int N = 2e5 + 5;
inline long long read() {
  long long x = 0;
  bool f = true;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = false;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return f ? x : -x;
}
long long gcd(long long m, long long n) { return n == 0 ? m : gcd(n, m % n); }
long long lcm(long long m, long long n) { return m * n / gcd(m, n); }
int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1), pre(n + 1), suf(n + 2);
  pre[0] = ~0;
  suf[n + 1] = ~0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] & (~a[i]);
  }
  for (int i = n; i >= 1; i--) {
    suf[i] = suf[i + 1] & (~a[i]);
  }
  int t0 = a[1] & suf[2];
  int t1 = a[n] & pre[n - 1];
  int pos = 1;
  for (int i = 1; i <= n - 1; i++) {
    if ((pre[i - 1] & a[i] & suf[i + 1]) > t0) {
      t0 = pre[i - 1] & a[i] & suf[i + 1];
      pos = i;
    }
  }
  if (t1 > t0) pos = n;
  swap(a[1], a[pos]);
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  return 0;
}
