n=1<<20 dp=[0]*n cum=[0]*n dp[1]=1 cum[1]=1 for i in range(2,n): if i%2==0: dp[i]=dp[i//2] else: dp[i]=1+min(dp[i//2],dp[(i+1)//2]) cum[i]=dp[i]+cum[i-1] for _ in range(int(input())): print(cum[int(input())])