#include using namespace std; void maimun() { ios::sync_with_stdio(false); cin.tie(0); } long long lastBiscuit(long long n) { long long highestPower = 1ULL << (63 - __builtin_clzll(n)); return 2 * (n - highestPower) + 1; } int main() { #ifdef ONLINE_JUDGE freopen("biscuits.in", "r", stdin); freopen("biscuits.out", "w", stdout); #endif maimun(); int n; cin >> n; while (n--) { long long biscuits; cin >> biscuits; cout << lastBiscuit(biscuits) << endl; }