#include <bits/stdc++.h>
using namespace std;
bool test_cases_exist = false;
void solve() {
  long long int i, j, n, m, k, x, y, ans;
  cin >> n;
  vector<long long int> v(n);
  for (auto &z : v) cin >> z;
  long long int bit = 23;
  long long int oneall = (1 << 23) - 1;
  vector<long long int> dp((1 << 23), -1);
  for (auto z : v) dp[z] = z;
  for (i = 0; i < (1 << bit); i++) {
    for (j = 0; j < bit; j++) {
      if (dp[i] != -1) break;
      if (i >> j & 1) dp[i] = dp[i ^ 1 << j];
    }
  }
  for (auto z : v) cout << dp[oneall ^ z] << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  if (test_cases_exist) cin >> t;
  while (t--) solve();
}
