#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MNOGO = 2e9;
const long long MD = 1e9 + 7;
const double EPS = 1e-10;
struct segmentTree {
  long long tl, tr;
  segmentTree* left;
  segmentTree* right;
  pair<long long, long long> val;
  pair<long long, long long> push;
  segmentTree(long long tl, long long tr)
      : tl(tl),
        tr(tr),
        left(nullptr),
        right(nullptr),
        val({0, tl}),
        push({0, tl}) {}
  segmentTree()
      : tl(1),
        tr((1 << 19)),
        left(nullptr),
        right(nullptr),
        val({0, tl}),
        push({0, tl}){};
  void createSons() {
    long long tm = (tl + tr) / 2;
    if (!left) {
      left = new segmentTree(tl, tm);
    }
    if (!right) {
      right = new segmentTree(tm + 1, tr);
    }
  }
  void doPush() {}
  void update(long long pos, pair<long long, long long> val) {
    doPush();
    if (tl == tr) {
      this->val = val;
      return;
    }
    createSons();
    long long tm = (tl + tr) / 2;
    if (pos <= tm) {
      left->update(pos, val);
    } else {
      right->update(pos, val);
    }
    this->val = min(left->val, right->val);
  }
  pair<long long, long long> get(long long l, long long r) {
    doPush();
    if (l > r) {
      return {INF, INF};
    }
    if (l == tl && tr == r) {
      return val;
    }
    long long tm = (tl + tr) / 2;
    createSons();
    return min(left->get(l, min(r, tm)), right->get(max(tm + 1, l), r));
  }
};
template <typename T>
ostream& operator<<(ostream& stream, const vector<T>& v) {
  for (auto i : v) {
    stream << i << " ";
  }
  return stream;
}
bool operator<(const pair<long long, long long>& p1,
               const pair<long long, long long>& p2) {
  if (p1.first < p2.first) return true;
  if (p1.first > p2.first) return false;
  return p1.second < p2.second;
}
long long p[200005];
long long n, m;
set<long long> g[200005];
map<pair<long long, long long>, bool> reb;
long long dsu_get(long long a) {
  if (p[a] == a) {
    p[a] = a;
    return a;
  } else {
    p[a] = dsu_get(p[a]);
    return p[a];
  }
}
void dsu_unite(long long a, long long b) {
  long long x = dsu_get(a);
  long long y = dsu_get(b);
  if (rand() % 2) {
    p[x] = y;
  } else {
    p[y] = x;
  }
}
segmentTree t;
bool used[200005];
void dfs(long long v, bool f) {
  used[v] = true;
  for (auto i : g[v]) {
    if (t.get(i, i).first != 2) {
      t.update(i, {1, i});
    }
  }
  t.update(v, {2, v});
  pair<long long, long long> tres = t.get(1, n);
  if (tres.first == 0) {
    long long to = tres.second;
    for (auto i : g[v]) {
      if (t.get(i, i).first != 2) {
        t.update(i, {0, i});
      }
    }
    dfs(to, 0);
    if (f) {
      dfs(v, 0);
    }
  } else {
    for (auto i : g[v]) {
      if (t.get(i, i).first != 2) {
        t.update(i, {0, i});
      }
    }
  }
}
long long a[1000006];
long long f(long long a, long long b) { return (a | b) - b; }
long long getbit(long long num, long long b) {
  if (num & (1ll << b)) {
    return 1;
  } else {
    return 0;
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  srand(time(NULL));
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long mx = 0;
  vector<long long> ans_v;
  long long first_num = -1;
  for (long long i = 32; i >= 0; i--) {
    long long cnt = 0;
    long long num = 0;
    for (long long j = 1; j <= n; j++) {
      if (getbit(a[j], i)) {
        cnt++;
        num = a[j];
      }
    }
    if (cnt == 1) {
      if (first_num == -1) {
        first_num = num;
        break;
      }
    }
  }
  if (first_num == -1) {
    for (long long i = 1; i <= n; i++) {
      cout << a[i] << " ";
    }
  } else {
    cout << first_num << " ";
    for (long long i = 1; i <= n; i++) {
      if (a[i] != first_num) {
        cout << a[i] << " ";
      }
    }
  }
}
