#include <bits/stdc++.h>
using namespace std;
long long int add(long long int a, long long int b) {
  return ((a % 1000000007 + b % 1000000007) % 1000000007);
}
long long int mult(long long int a, long long int b) {
  return (((a % 1000000007) * (b % 1000000007)) % 1000000007);
}
long long int gcdExtended(long long int a, long long int b, long long int *x,
                          long long int *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long int modInverse(long long int b, long long int m) {
  long long int x, y;
  long long int g = gcdExtended(b, m, &x, &y);
  if (g != 1) return -1;
  return (x % m + m) % m;
}
long long int modDivide(long long int a, long long int b, long long int m) {
  a = a % m;
  int inv = modInverse(b, m);
  return (inv * a) % m;
}
long long int power(long long int a, long long int n) {
  long long int ans = 1;
  while (n > 0) {
    long long int lastbit = (n & 1);
    if (lastbit) ans *= a;
    a *= a;
    n >>= 1;
  }
  return ans;
}
int sieveo(long long int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  long long int ans = 0;
  for (long long int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long int p = 2; p <= n; p++)
    if (prime[p]) ans++;
  return ans;
}
void primesieve(long long int N, long long int s[]) {
  vector<bool> prime(N + 1, false);
  for (long long int i = 2; i <= N; i += 2) s[i] = 2;
  for (long long int i = 3; i <= N; i += 2) {
    if (prime[i] == false) {
      s[i] = i;
      for (long long int j = i; j * i <= N; j += 2) {
        if (prime[i * j] == false) {
          prime[i * j] = true;
          s[i * j] = i;
        }
      }
    }
  }
}
void primefactor(long long int N) {
  long long int s[N + 1];
  primesieve(N, s);
  long long int curr = s[N];
  long long int cnt = 1;
  while (N > 1) {
    N /= s[N];
    if (curr == s[N]) {
      cnt++;
      continue;
    }
    curr = s[N];
    cnt = 1;
  }
}
void solve() {
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; ++i) cin >> a[i];
  long long int pref[n], suff[n];
  pref[0] = ~a[0];
  for (long long int i = 1; i < n; ++i) {
    pref[i] = (pref[i - 1] & ~a[i]);
  }
  suff[n - 1] = ~a[n - 1];
  for (long long int i = n - 2; i >= 0; --i) {
    suff[i] = (suff[i + 1] & (~a[i]));
  }
  long long int f[n], s[n];
  f[0] = a[0], s[n - 1] = a[n - 1];
  for (long long int i = 1; i < n; ++i) f[i] = pref[i - 1];
  for (long long int i = n - 2; i >= 0; --i) s[i] = suff[i + 1];
  long long int idx, mx = INT_MIN;
  for (long long int i = 0; i < n; ++i) {
    long long int cmp = f[i] & a[i] & s[i];
    if (cmp > mx) {
      mx = cmp;
      idx = i;
    }
  }
  cout << a[idx] << " ";
  for (long long int i = 0; i < n; ++i)
    if (i != idx) cout << a[i] << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
