#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> nums(n);
  for (int q = 0; q < n; q++) {
    cin >> nums[q];
  }
  int prefix[n], suffix[n];
  prefix[0] = nums[0];
  suffix[n - 1] = nums[n - 1];
  for (int q = 1; q < n; q++) {
    prefix[q] = nums[q] | prefix[q - 1];
    suffix[n - 1 - q] = suffix[n - q] | nums[n - 1 - q];
  }
  int mx = -1;
  int curnum = -1;
  for (int q = 0; q < n; q++) {
    int num = 0;
    if (q > 0) {
      num |= prefix[q - 1];
    }
    if (q < n - 1) {
      num |= suffix[q + 1];
    }
    num = ~num;
    if ((nums[q] & num) > mx) {
      mx = nums[q] & num;
      curnum = q;
    }
  }
  cout << nums[curnum];
  for (int q = 0; q < n; q++) {
    if (q != curnum) {
      cout << " " << nums[q];
    }
  }
  cout << "\n";
  return 0;
}
