__author__ = 'Admin'
import math
nt = int(raw_input())
for t in range(0, nt):
    n = int(raw_input())
    cnt = 0
    store_n = n
    while(n !=1):
        n = n/2
        cnt = cnt + 1
    # print cnt
    remainder = store_n - math.pow(2 , cnt)
    print int((remainder * 2)+1)