#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b > a) return gcd(b, a);
  return b == 0 ? a : gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long s[n];
  for (long long i = 0; i < n; i++) cin >> s[i];
  long long p[n];
  p[0] = (~(s[0]));
  for (long long i = 1; i < n; i++) p[i] = p[i - 1] & (~s[i]);
  long long suf[n];
  suf[n - 1] = (~(s[n - 1]));
  for (long long i = n - 2; i >= 0; i--) suf[i] = suf[i + 1] & (~s[i]);
  long long q = 0, id = 0, ans = 0;
  for (long long i = 0; i < n; i++) {
    if (i == 0)
      q = s[0] & suf[1];
    else if (i == n - 1)
      q = s[n - 1] & p[n - 2];
    else
      q = (s[i] & (p[i - 1]) & (suf[i + 1]));
    if (q > ans) {
      ans = q;
      id = i;
    }
  }
  cout << s[id] << " ";
  for (long long i = 0; i < n; i++)
    if (i != id) cout << s[i] << " ";
  return 0;
}
