import sys input = sys.stdin.readline T=int(input()) for tests in range(T): N=int(input())+1 P=1 ANS=0 for i in range(1,51): P*=2 ANS+=N//P * (P//2) rest=N%P ANS+=max(rest-P//2,0) print(ANS)