for _ in range(int(input())): N=int(input())+1 ans=0 for i in range(50): tw=2**i cnt=N//(tw*2) amr=N%(tw*2) ans+=cnt*tw ans+=max(amr-tw,0) print(ans)