#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr int mod = 1e9 + 7;
template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}
struct RangeOrQuery {
  using type = int;
  static type id() { return 0; }
  static type op(const type &l, const type &r) { return (l | r); }
};
template <typename M>
class SegmentTree {
  using T = typename M::type;
  int n;
  std::vector<T> node;

 public:
  SegmentTree(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    node.resize(2 * n, M::id());
  }
  void update(int x, T val) {
    x += n;
    node[x] = val;
    while (x >>= 1) {
      node[x] = M::op(node[2 * x], node[2 * x + 1]);
    }
  }
  void operation(int x, T val) {
    x += n;
    node[x] = M::op(node[x], val);
    while (x >>= 1) {
      node[x] = M::op(node[2 * x], node[2 * x + 1]);
    }
  }
  T query(int l, int r) {
    l += n;
    r += n;
    T retl = M::id(), retr = M::id();
    while (l < r) {
      if (l & 1) retl = M::op(retl, node[l++]);
      if (r & 1) retr = M::op(node[--r], retr);
      l >>= 1;
      r >>= 1;
    }
    return M::op(retl, retr);
  }
};
const int MAX_N = 100010;
SegmentTree<RangeOrQuery> seg(MAX_N);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    seg.update(i, a[i]);
  }
  if (n == 1) {
    printv(a);
    return 0;
  }
  int index = -1, ma = -1;
  for (int i = 0; i < n; i++) {
    int x = 0;
    if (i != 0) x |= seg.query(0, i);
    if (i != n - 1) x |= seg.query(i + 1, n);
    int tmp = a[i] & (~x);
    if (tmp > ma) {
      ma = tmp;
      index = i;
    }
  }
  if (index != 0) swap(a[0], a[index]);
  printv(a);
}
