from functools import reduce num = int(input()) for _ in range(num): print(reduce(lambda x,y:x+ bin(y)[2:].count("1"),range(1,int(input())+1)))