Q = int(input()) for _ in range(Q): N = int(input()) ans = 0 for k in range(1, 64): K = 1 << k rem = (N + 1) % K ans += (N + 1) // K * (K >> 1) + max(0, rem - (K >> 1)) print(ans)