#include <bits/stdc++.h>
using namespace std;
void read(long long &x) { scanf("%lld", &x); }
void read(long long &x, long long &y) { scanf("%lld%lld", &x, &y); }
void read(long long &x, long long &y, long long &z) {
  scanf("%lld%lld%lld", &x, &y, &z);
}
void print(long long x) { printf("%lld ", x); }
void println(long long x) { printf("%lld\n", x); }
const long long N = 200100;
long long n, a[N], s = (1LL << 30) - 1, l[N], r[N], ans = -1, pos;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  l[0] = r[n + 1] = s;
  for (long long i = 1; i <= n; i++) l[i] = (l[i - 1] & (s ^ a[i]));
  for (long long i = n; i >= 1; i--) r[i] = (r[i + 1] & (s ^ a[i]));
  for (long long i = 1; i <= n; i++)
    if ((a[i] & l[i - 1] & r[i + 1]) > ans)
      ans = (a[i] & l[i - 1] & r[i + 1]), pos = i;
  cout << a[pos] << " ";
  for (long long i = 1; i <= n; i++)
    if (i != pos) cout << a[i] << " ";
}
