#include using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { int64_t x; cin >> x; int mn = -1, mx = -1; for (int j = 0; (1 << j) <= x; ++j) { if ((1 << j) & x) { if (mn == -1) mn = j; } else mx = j; } if (mn == -1 or mx == -1) cout << x << ' '; else { int64_t bst = x; x -= 1 << mn, x += 1 << (mx); cout << max(bst, x) << ' '; } } }