#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
  return x * f;
}
long long n, A[1000010], B[1000010], Now[1000010], Sum = -1, sum = -1, Ans = -1,
                                                   Place = -1;
signed main() {
  n = read();
  for (register long long i = (1), iLimit = (n); i <= iLimit; (++(i)))
    A[i] = read(), B[i] = B[i - 1] | A[i];
  for (register long long i = (n), iLimit = (1); i >= iLimit; (--(i)))
    Now[i] = Now[i + 1] | A[i];
  for (register long long i = (1), iLimit = (n); i <= iLimit; (++(i))) {
    Sum = B[i - 1] | Now[i + 1], sum = (A[i] | Sum) - Sum;
    if (sum > Ans) Ans = sum, Place = i;
  }
  printf("%lld ", A[Place]);
  for (register long long i = (1), iLimit = (n); i <= iLimit; (++(i)))
    if (i != Place) printf("%lld ", A[i]);
  return 0;
  long long zmytxdy = 31231321;
  long long zzzakioi = 12312312;
  long long hhh = 1231983018;
}
