def solve(N):
	if N==1: return 1
	if N%2==0:
		return solve(N/2) + (N/2)**2
	else:
		return ((N+1)/2)**2 + solve(N/2)
		
rr = raw_input
for testcase in xrange(int(rr())):
	N = int(rr())
	print solve(N)