for _ in range(int(input())): N = int(input()) ans = 0 s = 0 for j in range(40,0,-1): if (N >> j) & 1: c = 1 << (j - 1) ans += (2 * s + j) * c s += 1 if N % 2: ans += s s += N % 2 print(ans + s)