#include using namespace std; using i64 = long long; i64 mod(i64 v) { if (v <= 1) return v; i64 a = 1, b = 1; for (i64 i = 1; i <= v; i<<= 1) if (v & i) { a = i; break; } for (i64 i = 1; i <= v; i<<= 1) { if (~v & i) b = i; } return v ^ a ^ b; } int main() { //freopen("dat.in", "r", stdin); ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int n; i64 t; cin >> n; for (int i = 1; i <= n; ++i) { cin >> t; cout << max(t, mod(t)) << " \n"[i == n]; } return 0; }