#include using namespace std; // Optimization stuff inline void debugMode() { #ifndef ONLINE_JUDGE freopen("debug.in", "r", stdin); #endif // ONLINE_JUDGE } inline void optimizeIt() { ios::sync_with_stdio(false); cin.tie(NULL); } // End optimization stuff inline double ABS(const int &x) { return max(x, -x); } inline bool isPrime(const int &x) { if(x == 1) return false; for(int d = 2; d * d <= x; d++) { if(x % d == 0) return false; } return true; } typedef long long int ll; typedef long double ld; const int NMax = 1e5 + 5; const int LIM = 1e6; const int MOD = 666013; int main(){ debugMode(); optimizeIt(); int n; cin >> n; for(int i = 1; i <= n; i++) { ll x; cin >> x; vector < int > v; while(x) { v.push_back(x % 2); x /= 2; } int posOne = -1; int posZer = -1; for(int i = 0; i < (int)v.size() - 1; i++) { if(v[i] == 1 && posOne == -1) posOne = i; if(v[i] == 0) posZer = i; } if(posOne != -1 && posZer != -1 && posZer > posOne) swap(v[posOne], v[posZer]); ll ans = 0; for(int i = 0; i < (int)v.size(); i++) { if(v[i] == 1) { ans = ans + (1LL << i); } } cout << ans << " "; } return 0; }