#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433;
const long long M = 1743;
long long t, n, x[100100], p, k, m, s, a[50], pp[50];
bitset<34> b[100100];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  pp[0] = 1;
  for (long long i = 1; i < 33; i++) {
    pp[i] = pp[i - 1] * 2;
  }
  for (long long i = 0; i < n; i++) {
    cin >> x[i];
    b[i] = x[i];
    for (long long j = 0; j < 33; j++)
      if (b[i][j] == 1) a[j]++;
  }
  k = 0;
  m = x[0];
  for (long long i = 0; i < n; i++) {
    p = 0;
    for (long long j = 0; j < 33; j++) {
      if (b[i][j] == 1 && a[j] == 1) {
        p += pp[j];
      }
    }
    if (p > k) {
      k = p;
      m = x[i];
    }
  }
  cout << m << " ";
  for (long long i = 0; i < n; i++) {
    if (x[i] == m) {
      m = -10;
      continue;
    }
    cout << x[i] << " ";
  }
}
