t = int(input()) x = 40 for _ in range(t): n = int(input()) + 1 ans = 0 for i in range(x): p = 2 ** (i + 1) ans += (n//p)*p//2 ans += max(0,n%p-p//2) print(ans)