#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main() { int t; std::cin >> t; while (t--) { int n; std::cin >> n; int maxBits = 60; std::vector bitCounts(maxBits, 0); for (int i = 0; i < maxBits; i++) { long long blockSize = (1LL << (i + 1)); // 2^(i+1) long long fullBlocks = n / blockSize; long long remainder = n % blockSize; long long count = fullBlocks * (1LL << i); long long limit = (1LL << i); if (remainder >= limit) { count += (remainder - limit + 1); // 0 based, so + 1 } bitCounts[i] = count; } long long result = std::accumulate(bitCounts.begin(), bitCounts.end(), 0LL); std::cout << result << '\n'; } }