#CF598A. Tricky Sum

Tricky Sum

题目描述

In this problem you are to calculate the sum of all integers from 1 1 to n n , but you should take all powers of two with minus in the sum.

For example, for n=4 n=4 the sum is equal to 12+34=4 -1-2+3-4=-4 , because 1 1 , 2 2 and 4 4 are 20 2^{0} , 21 2^{1} and 22 2^{2} respectively.

Calculate the answer for t t values of n n .

输入格式

The first line of the input contains a single integer t t ( 1<=t<=100 1<=t<=100 ) — the number of values of n n to be processed.

Each of next t t lines contains a single integer n n ( 1<=n<=109 1<=n<=10^{9} ).

输出格式

Print the requested sum for each of t t integers n n given in the input.

题目大意

简明题意:

该题目有多组数据,每组数据给出一个n,让你求出从1到n的和,但是其中每当遇到一个数是2的次幂时,就要变加为减。例如输入n=4,那么计算算式为-1-2+3-4=-4,因为1是2^0,2是2^1,4是2^2。共有t组数据。

2
4
1000000000

-4
499999998352516354

提示

The answer for the first sample is explained in the statement.