#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using pii = pair<int, int>; #define dbg(x) cerr<<#x": "<<(x)<<'\n' #define dbg_v(x, n) cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<'\n' #define all(v) v.begin(), v.end() #define NMAX int main() { #ifndef ONLINE_JUDGE ifstream cin("data.in"); ofstream cout("data.out"); #endif ios_base::sync_with_stdio(false); int i, n, first0, last1, ok, x, y, bit; for(cin >> n; n; --n) { cin >> x; y = x; ok = false, first0 = last1 = -1; for(bit = 31; bit >= 0; --bit) if(x & (1 << bit)) { if(ok == false) ok = true; last1 = bit; } else if(ok && first0 == -1) first0 = bit; if(first0 == -1 || last1 == -1) cout << y << ' '; else cout << max(y, (y | (1 << first0)) ^ (1 << last1)) << ' '; } cout << '\n'; return 0; }