#include #include #define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) using namespace atcoder; using namespace std; typedef long long ll; int main() { int t; cin >> t; while (t--) { ll n; cin >> n; n++; ll ans = 0; ll nw = 2; while (nw <= 3e12) { ll am = n % nw; ll cnt = n / nw; ans += cnt * (nw / 2); ans += max(0LL, am - nw / 2); nw *= 2; } cout << ans << endl; } }