#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define PI(x) printf("%d",x)
#define SI(x) scanf("%d",&x)
#define P_(x) printf(" ")
const int INF=0x3f3f3f3f;
typedef long long LL;
int main(){
LL n;
int T;
SI(T);
while(T--){
LL temp=0,i=0;
scanf("%lld",&n);
while(pow(2,i)<=n){
temp+=pow(2,i);
i++;
}
printf("%lld\n",n*(n+1)/2-2*temp);
}
return 0;
}
c++的使用,用来计算数列和,其中凡是2的次方数均为负数;