from sys import stdin
for _ in range(int(stdin.readline())):
    n = int(stdin.readline())
    t = 1
    res = 0
    while True:
        res += t
        t *= 2
        if t > n:
            break
    res = n * (n + 1) // 2 - 2 * res
    print(res)

f36f447d5c90f56d761c0e0dd2ab2255e93cfdcc
<mask token>

<mask token>
for _ in range(int(stdin.readline())):
    n = int(stdin.readline())
    t = 1
    res = 0
    while True:
        res += t
        t *= 2
        if t > n:
            break
    res = n * (n + 1) // 2 - 2 * res
    print(res)

from sys import stdin
for _ in range(int(stdin.readline())):
    n = int(stdin.readline())
    t = 1
    res = 0
    while True:
        res += t
        t *= 2
        if t > n:
            break
    res = n * (n + 1) // 2 - 2 * res
    print(res)
