t=int(input()) for _ in range(t): n=int(input())+1 ans=0 for i in range(60): ans+=n//2**(i+1)*2**i+max(0,n%2**(i+1)-2**i) print(ans)