#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1048576 * 4;
int v[MAXN];
int freq[MAXN];
int st[4 * MAXN];
void merge(int nd0, int nd1, int sz) {
  if (sz == 1) {
    if (st[nd1] == -1) st[nd1] = st[nd0];
    return;
  }
  int nxt0 = nd0 << 1;
  int nxt1 = nd1 << 1;
  merge(nxt0, nxt1, sz >> 1);
  merge(nxt0 + 1, nxt1 + 1, sz >> 1);
}
void build(int nd, int l, int r) {
  if (l == r) {
    st[nd] = freq[l] ? l : -1;
    return;
  }
  int mid = (l + r) >> 1;
  int nxt = nd << 1;
  build(nxt, l, mid);
  build(nxt + 1, mid + 1, r);
  merge(nxt, nxt + 1, mid - l + 1);
}
int query(int nd, int l, int r, int x) {
  if (l == r) return st[nd];
  int mid = (l + r) >> 1;
  int nxt = nd << 1;
  if (x <= mid) return query(nxt, l, mid, x);
  return query(nxt + 1, mid + 1, r, x);
}
void prnt(int nd, int l, int r) {
  if (l == r) {
    cout << l << " " << st[nd] << endl;
    return;
  }
  int mid = (l + r) >> 1;
  int nxt = nd << 1;
  prnt(nxt, l, mid);
  prnt(nxt + 1, mid + 1, r);
  return;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", v + i);
    freq[v[i]]++;
  }
  build(1, 0, MAXN - 1);
  for (int i = 0; i < n; ++i) {
    int val = (~v[i]) & (MAXN - 1);
    printf("%d%c", query(1, 0, MAXN - 1, val), (i == n - 1) ? '\n' : ' ');
  }
  return 0;
}
