#include <bits/stdc++.h>
int mod;
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& os, pair<S, T> p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (int i = 0; i < int((v).size()); i++) os << v[i] << " ";
  return os << "]";
}
long long INF = (1ll << 61);
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  if (n == 1) {
    cout << v[0] << endl;
    return 0;
  }
  vector<long long> a(n), b(n);
  a = b = v;
  for (int i = 1; i < n; i++) a[i] = a[i - 1] | v[i];
  for (int i = n - 2; i >= 0; i--) b[i] = b[i + 1] | v[i];
  long long ans = 0;
  int x = 0;
  for (int i = 0; i < n; i++) {
    long long c;
    if (i == 0) {
      c = (v[i] | b[i + 1]) - b[i + 1];
    } else if (i == n - 1) {
      c = (v[i] | a[i - 1]) - a[i - 1];
    } else {
      int k = a[i - 1] | b[i + 1];
      c = (v[i] | k) - k;
    }
    if (c > ans) {
      x = i;
      ans = c;
    }
  }
  cout << v[x] << " ";
  for (int j = 0; j < n; j++) {
    if (j != x) {
      cout << v[j] << " ";
    }
  }
  cout << endl;
  return 0;
}
