#include <bits/stdc++.h>
using namespace std;
const long long int M = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t, n, i, j, k;
  cin >> n;
  long long int p2[32] = {0};
  long long int res = 1;
  for (long long int i = 0; i < 32; i++) {
    p2[i] = res;
    res *= 2;
  }
  vector<long long int> arr(n);
  long long int b[32] = {0};
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    k = arr[i];
    long long int c = 0;
    while (k) {
      b[c++] += k % 2;
      k /= 2;
    }
  }
  long long int ans, ans1 = -1;
  for (long long int i = 0; i < n; i++) {
    long long int a[32] = {0};
    k = arr[i];
    long long int c = 0;
    while (k) {
      a[c++] = k % 2;
      k /= 2;
    }
    long long int temp = 0;
    for (long long int j = 0; j < 32; j++) {
      if (b[j] == 1 && b[j] == a[j]) {
        temp += (p2[j]);
      }
      if (temp > ans1) {
        ans1 = temp;
        ans = i;
      }
    }
  }
  t = arr[ans];
  arr.erase(arr.begin() + ans);
  arr.insert(arr.begin(), t);
  for (auto it = arr.begin(); it != arr.end(); it++) cout << *it << " ";
  cout << "\n";
  return 0;
}
