#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i) #define all(a) (a).begin(), (a).end() int main() { cin.tie(nullptr); int T; cin >> T; rep(test, 0, T) { ll N; cin >> N; int d = 0; ll t = N; while (t > 0) { d++; t >>= 1; } ll ans = 0; ll fac = 1; rep(i, 0, d) { ans += (N / (fac * 2)) * fac + max(0ll, N % (fac * 2) - fac + 1); fac *= 2; } cout << ans << '\n'; } }