#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5;
int a[N], cur[N];
pair<int, int> b[N];
signed main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 0; j < 30; j++) {
      if (a[i] & (1 << j)) cur[j]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    b[i] = make_pair(0, a[i]);
    for (int j = 0; j < 30; j++) {
      if (a[i] & (1 << j) && cur[j] == 1) b[i].first |= (1 << j);
    }
  }
  sort(b + 1, b + 1 + n);
  for (int i = n; i >= 1; i--) {
    cout << b[i].second << " ";
  }
  return false;
}
