#include using namespace std; using uint = unsigned int; using ll = long long; using pii = pair; #define dbg(x) cerr<<#x": "<<(x)<<'\n' #define dbg_v(x, n) cerr<<#x"[]: ";for(long long _=0;_> 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; }