for _ in range(int(raw_input())):
    m=int(raw_input())
    n=list(bin(m))
    n.append("1")
    n.pop(2)
    
    dec=0
    j=len(n)-3
    for i in range(2,len(n)):
        if n[i]!="0":
            dec=dec+2**j
        j-=1
    print(dec)