for _ in range(input()):
    n1 = input()
    sums = 0
    while n1>0:
        if n1%2 == 1:
            j = (n1/2) + 1
        else:
            j = n1/2
        sums += j * j
        n1 = n1 - j
    print(sums)