#include <bits/stdc++.h>
using namespace std;
std::string rla;
bool CASE = 0;
template <typename _tp>
bool wi(_tp &_va) {
  _va = 0;
  long double va = 0.0, vd = 0.1;
  bool _neg = 0;
  auto _rd = getchar();
  while (_rd < '0' || _rd > '9') {
    if (_rd == '-') {
      _neg = 1;
    } else if (_rd == -1) {
      return 0;
    }
    _rd = getchar();
  }
  {
    while (_rd >= '0' && _rd <= '9')
      _va = _va * 10 + (_tp)_rd - 48, _rd = getchar();
  }
  {
    if (_rd == '.')
      while (_rd = getchar(), '0' <= _rd && _rd <= '9')
        va = va + ((_tp)_rd - 48) * vd, vd /= 10;
  }
  _va = (1 - _neg * 2) * (_va + (_tp)va);
  return 1;
}
template <typename _tp>
void wo(_tp _var, int _nline = 0) {
  static char _wri[64];
  int _tpi = 0;
  {
    if (_var < 0) putchar('-'), _var *= -1;
  }
  do {
    _wri[_tpi++] = (char)((_var % 10) + 48), _var /= 10;
  } while (_var);
  {
    while (_tpi) putchar(_wri[--_tpi]);
  }
  if (_nline) putchar(_nline == 1 ? '\n' : ' ');
}
bool rstr(std::string &_var, bool _ed = 0) {
  std::string _tmp;
  auto _ch = getchar();
  {
    while (_ch <= 32)
      if (_ch == -1) {
        return 0;
      } else {
        _ch = getchar();
      }
  }
  {
    while (((_ch != ' ') | _ed) && _ch != '\n' && _ch >= 0)
      _tmp.push_back((char)_ch), _ch = getchar();
  }
  _var = _tmp;
  return 1;
}
void pstr(std::string _var, int _nline = 0) {
  unsigned long long _len = _var.length(), _it = 0;
  {
    while (++_it <= _len) putchar(_var[_it - 1]);
  }
  if (_nline) putchar(_nline < 2 ? '\n' : ' ');
}
const int inf = 0x3f3f3f3f;
const long long mod = 998244353;
const int maxn = 1e5;
int n, m;
int li[maxn | 1];
inline void solve() {
  n = stoi(rla);
  int k[32] = {0};
  for (int i = 1; i <= (int)n; i++) {
    wi(li[i]);
    for (int j = 0; j < 32; j++) k[j] += (li[i] >> j) & 1;
  }
  int p = 0;
  for (int i = 32; i; i--)
    if (k[i] == 1) {
      p = i;
      break;
    }
  for (int i = 1; i <= (int)n; i++)
    if ((li[i] >> p) & 1) {
      swap(li[i], li[1]);
      break;
    }
  for (int i = 1; i <= (int)n; i++) wo(li[i], 1 + (i != n));
}
int main() {
  while (rstr(rla)) {
    int cases = CASE ? (std::stoi(rla)) : 1;
    for (int cas = 1; cas <= cases; cas++) {
      solve();
    }
  }
  return 0;
}
