import math
#def josep(n):
 #   if n==1:
   #     return 1
   # else:
     #   return (josep(n-1)+1)%n +1
def jos(n):
    a=int( math.log(n,2))
    w=(2**a)
    w=2*(n-w)+1
    return  w
for i in range(input()):
    print jos(input())