#include <bits/stdc++.h>
using namespace std;
inline int f(int r, int s) { return (r | s) - s; }
int n, a[100002], b[33], u;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < 33; ++i) b[i] = -1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    u = a[i];
    int pos = 0;
    while (u) {
      if (u & 1) {
        if (b[pos] == -1)
          b[pos] = i;
        else
          b[pos] = -2;
      }
      ++pos, u >>= 1;
    }
  }
  int ans = 0, mark = 0;
  for (int i = 0; i < n; ++i) {
    int ret = 0;
    u = a[i];
    int pos = 0;
    while (u) {
      if (u & 1) {
        if (b[pos] == -1 || b[pos] == i) ret += (1 << pos);
      }
      ++pos, u >>= 1;
    }
    if (ret >= ans) {
      ans = ret;
      mark = i;
    }
  }
  cout << a[mark] << ' ';
  for (int i = 0; i < n; ++i) {
    if (i != mark) cout << a[i] << ' ';
  }
  return 0;
}
