import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from functools import lru_cache @lru_cache(maxsize=None) def f(n): if n <= 0: return 0 now = 0 for i in range(1, 65): if 2 ** i - 1 > n: break now = 2 ** i - 1 r = n - now return f(now // 2) * 2 + (now + 1) // 2 + f(r - 1) + r T = int(input()) for _ in range(T): N = int(input()) print(f(N))