#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
map<pair<long long, long long>, bool> mp;
void dfs(vector<long long> adj[], vector<long long> &vis, long long src,
         long long &ver) {
  vis[src] = 1;
  ver++;
  for (auto i : adj[src]) {
    if (!vis[i]) {
      dfs(adj, vis, i, ver);
    }
    mp[{i, src}] = true;
    mp[{src, i}] = true;
  }
}
int main() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int i = 0;
  while (arr[n - 1] > (1 << i)) {
    i++;
  }
  for (; i >= 0; i--) {
    long long ans = (1 << i);
    long long cnt = 0;
    for (long long j = 0; j < n; j++) {
      if (ans & arr[j]) {
        cnt++;
      }
    }
    if (cnt == 1) {
      break;
    }
  }
  if (i < 0) {
    for (long long i = 0; i < n; i++) cout << arr[i] << " ";
  } else {
    int ind = -1;
    for (long long j = 0; j < n; j++) {
      if (arr[j] & (1 << i)) {
        ind = j;
        break;
      }
    }
    swap(arr[ind], arr[0]);
    for (long long i = 0; i < n; i++) cout << arr[i] << " ";
  }
}
