#include #include using namespace std; int t,cnt,now; unsigned long long f[110],l[110],m,ans[2]; void work(unsigned long long m) { if(!m)return; int now=upper_bound(l+1,l+1+cnt,m)-l-1; if(l[now]==m) { ans[0]+=f[now]; if(ans[0]>=1e18)ans[1]+=ans[0]/100000000000000000ll,ans[0]%=100000000000000000ll; return; } work(m-l[now]-1); ans[0]+=m-l[now]; if(ans[0]>=1e18)ans[1]+=ans[0]/100000000000000000ll,ans[0]%=100000000000000000ll; ans[0]+=f[now]; if(ans[0]>=1e18)ans[1]+=ans[0]/100000000000000000ll,ans[0]%=100000000000000000ll; } int main() { scanf("%d",&t); f[1]=l[1]=1; for(int i=2;i<=100;i++) { l[i]=l[i-1]*2+1; f[i]=f[i-1]*2+l[i-1]+1; if(l[i]>=1e16) { cnt=i; break; } } while(t--) { ans[0]=ans[1]=0; scanf("%I64u",&m); work(m); now=upper_bound(l+1,l+1+cnt,m)-l-1; if(!ans[0])ans[0]+=m-l[now]; if(ans[1])printf("%I64u",ans[1]); printf("%I64u\n",ans[0]); } }