#include <iostream> #define zeros(x) x&(x-1)^x #define LL long long using namespace std; LL n,x,mx,nr,y,sav; LL swap(int k) { LL a = x & (1<<k); LL b = x & (1<<(k+1)); y = x; a = a<<1; b = b>>1; if (a!=0 && b==0) { y = y | a; y = y ^ (a>>1); } return y; } int main() { cin>>n; for (int i=1;i<=n;i++) { cin>>x; mx = x; if (x<=1) { cout<<mx<<' '; continue; } nr=1; LL aux = 1; while (aux*2<=x) { nr++; aux*=2; if ((x&aux)==0) sav = aux; } if (sav>zeros(x)) { aux = zeros(x); x = x ^ aux; x = x | sav; } cout<<x<<' '; } return 0; }