#include #include #include #include #define maxn 2010 using namespace std; #define oo 1000000000000000000 typedef unsigned long long ull; typedef long long ll; int T, up; ll n, len[maxn]; ull a[maxn]; ull get(ll x) { if (x <= 0) return 0; int pos = upper_bound(len + 1, len + up + 1, x) - len - 1; if (len[pos] == x) return a[pos]; ull ret = a[pos] + 1ull + get(x - len[pos] - 1ull) + x - len[pos] - 1ull; //printf("get(%lld) = %llu\n", x, ret); //printf("a[%d] = %llu\n", pos, a[pos]); return ret; } void solve() { scanf("%llu", &n); printf("%llu\n", get(n)); } int main() { a[1] = 1; len[1] = 1; for (int i = 2; i <= 100; ++ i){ len[i] = len[i - 1] * 2 + 1; a[i] = a[i - 1] + a[i - 1] + len[i - 1] + 1; if (len[i] > 1e16){ up = i; break;} } scanf("%d", &T); while (T --) solve(); //for (int i = 1; i < 100010; ++ i) printf("%llu\n", get(i)); return 0; }