#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 6;
const long long mx = 1e9;
int a[N], p[36] = {1}, c[36], Ans, id;
vector<pair<int, int> > b;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t, n, m;
  cin >> n;
  for (int i = 1; i <= 30; i++) p[i] = p[i - 1] * 2;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 0; j <= 30; j++)
      if (a[i] & p[j]) c[j]++;
  }
  for (int k = 1; k <= n; k++) {
    int ans = a[k];
    for (int i = 0; i <= 30; i++)
      if (p[i] & a[k]) c[i]--;
    for (int i = 0; i <= 30; i++)
      if (c[i]) ans -= (ans & p[i]);
    for (int i = 0; i <= 30; i++)
      if (p[i] & a[k]) c[i]++;
    Ans = max(Ans, ans);
    if (Ans == ans) id = k;
  }
  cout << a[id];
  for (int i = 1; i <= n; i++)
    if (i != id) cout << ' ' << a[i];
  cout << endl;
  return 0;
}
