#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005, maxm = 55;
const long long mod = 1000000007;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long powermod(long long a, long long b, long long c) {
  a = a % c;
  long long ans = 1;
  while (b) {
    if (b % 2) ans = (ans * a) % c;
    b = b / 2;
    a = (a * a) % c;
  }
  return ans;
}
long long a[100005];
long long flag[100];
int main() {
  long long n, i, j, k, ans = 0;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    long long x = a[i];
    long long cnt = 0;
    while (x) {
      if (x % 2 == 1) flag[cnt]++;
      x = x / 2;
      cnt++;
    }
  }
  long long maxx = -1, pos = 0;
  for (i = 1; i <= n; i++) {
    long long k = 1;
    long long x = a[i];
    long long cnt = 0;
    long long num = 0;
    while (x) {
      if (x % 2 == 1 && flag[cnt] == 1) num = num + k;
      x = x / 2;
      k = k * 2;
      cnt++;
    }
    if (num > maxx) {
      maxx = num;
      pos = i;
    }
  }
  printf("%lld ", a[pos]);
  for (i = 1; i <= n; i++) {
    if (i != pos) printf("%lld ", a[i]);
  }
  printf("\n");
}
