#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int T; cin >> T; while(T--){ ll N, S=0, p=1, x, y; cin >> N; N++; for (int i=1; i<40; i++){ x = N / (p*2); y = N % (p*2); S += x*p; S += max(0LL, y-p); p *= 2; } cout << S << endl; } return 0; }