#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int z[1000000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int b[n][32];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 32; j++) b[i][j] = 0;
  int j, x;
  for (int i = 0; i < n; i++) {
    j = 31;
    x = a[i];
    while (x > 0) {
      b[i][j] = x % 2;
      x /= 2;
      j--;
    }
  }
  int y;
  vector<int> w;
  for (int j = 0; j < 32; j++) {
    x = 0;
    for (int i = 0; i < n; i++) {
      if (b[i][j] == 1) {
        x++;
        y = i;
      }
    }
    if (x == 1) w.push_back(y);
  }
  vector<int> vis(n, 0);
  for (int i = 0; i < w.size(); i++) {
    if (!vis[w[i]]) cout << a[w[i]] << " ";
    vis[w[i]] = 1;
  }
  for (int i = 0; i < n; i++)
    if (!vis[i]) cout << a[i] << " ";
}
