#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int &i : a) cin >> i;
  int single = 0;
  long long x = 1;
  for (int j = 0; j < 31; j++) {
    bool flag = 0;
    for (int i = 0; i < n; i++) {
      if (!flag)
        flag = x & a[i];
      else if (x & a[i]) {
        flag = 0;
        break;
      }
    }
    if (flag) single |= x;
    x <<= 1;
  }
  int m = 0, top;
  for (int i = 0; i < n; i++)
    if (m < (single & a[i])) {
      m = single & a[i];
      top = a[i];
    }
  if (single != 0) cout << top << " ";
  bool flag = !single;
  for (int i = 0; i < n; i++) {
    if (flag || a[i] != top) cout << a[i] << " ";
    if (a[i] == top) flag = true;
  }
  return 0;
}
