598A- python3 from math import log2 def sum_until_n(n): return n*(n+1)/2 def sum_of_squares(n): return 2**(int(log2(n))+1)-1
m=int(input()) res=[] for i in range(m): n=int(input()) k=int(sum_until_n(n)-(2*sum_of_squares(n))) res.append(k) for v in res: print(v)