#include #include #include #include #include using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("a.in", "r", stdin); freopen("a.out", "w", stdout); #endif int n; cin >> n; for (int i = 1; i <= n; ++i) { long long x; cin >> x; int last0 = -1, first1 = -1; for (int nrBits = 0; (1LL << nrBits) <= x; ++nrBits) { if ((x & (1LL << nrBits)) == 0) last0 = nrBits; else if (first1 == -1) first1 = nrBits; } if (first1 != -1 && last0 != -1) { if (first1 < last0) { x -= (1LL << first1); x += (1LL << last0); } } cout << x << " "; } return 0; }