#include <bits/stdc++.h>
const int N = 1e5 + 1;
int n, a[N];
std::mt19937 gen(3711);
const int GN = 10, GM = 1000;
void genR() {
  n = 10;
  for (int i = 0; i < n; ++i) a[i] = gen() % GM + 1;
}
int F() {
  int res = a[0];
  for (int i = 1; i < n; ++i) res = (res | a[i]) - a[i];
  return res;
}
int b[N], bans;
void brut() {
  bans = -1;
  std::sort(a, a + n);
  do {
    int cur = F();
    if (bans <= cur) {
      bans = cur;
      for (int i = 0; i < n; ++i) b[i] = a[i];
    }
  } while (std::next_permutation(a, a + n));
}
void read() {
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> a[i];
}
const int C = 30;
int bl9[C], bl9_id;
int doubt() {
  for (int j = 0; j < C; ++j) bl9[j] = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < C; ++j)
      if ((a[i] >> j) & 1) ++bl9[j];
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int res = 0;
    for (int j = 0; j < C; ++j) {
      if (((a[i] >> j) & 1) && bl9[j] == 1) res |= 1 << j;
    }
    if (ans < res) bl9_id = i;
    ans = std::max(ans, res);
  }
  return ans;
}
int bl9_check(std::vector<int>& kuda) {
  kuda.clear();
  kuda.push_back(bl9_id);
  for (int i = 0; i < n; ++i)
    if (i != bl9_id) kuda.push_back(i);
  int res = a[kuda[0]];
  for (int i = 1; i < n; ++i) res = (res | a[kuda[i]]) - a[kuda[i]];
  return res;
}
int main() {
  read();
  doubt();
  std::vector<int> aaaaaaaa;
  bl9_check(aaaaaaaa);
  for (int i : aaaaaaaa) std::cout << a[i] << " ";
  return 0;
  while (true) {
    genR(), brut();
    int res = doubt();
    std::vector<int> idx;
    int lol = bl9_check(idx);
    if (lol != res) {
      std::cout << "Bl9" << std::endl;
      for (int i : idx) std::cout << i << " ";
      std::cout << res << " " << lol << " " << bans << std::endl;
    } else
      std::cout << "lolkek" << std::endl;
    if (doubt() != bans) {
      std::cout << "DD " << bans << " " << doubt() << std::endl;
      for (int i = 0; i < n; ++i) std::cout << b[i] << " ";
      std::cout << "\n";
      for (int i = 0; i < n; ++i) {
        for (int j = 8; j >= 0; --j) {
          std::cout << ((b[i] >> j) & 1);
        }
        std::cout << "\n";
      }
      char c;
      std::cin >> c;
    } else
      std::cout << "passed" << std::endl;
  }
}
