def II() -> int : return int(input()) def MI() -> int : return map(int, input().split()) def TI() -> tuple[int] : return tuple(MI()) def LI() -> list[int] : return list(MI()) class fenwick_tree(): n=1 data=[0 for i in range(n)] def __init__(self,N): self.n=N self.data=[0 for i in range(N)] def add(self,p,x): assert 0<=p0): s+=self.data[r-1] r-=r&-r return s t = II() for _ in range(t): n = II() + 1 ans = 0 for i in range(30): s = 1<>i & 1: #立っているとき ans += (n//(s*2)) * s ans += n%s else: ans += (n//(s*2)) * s print(ans)