import sys
def remaining( n, k):
r = 0
i = 2
while i <= n:
r = (r + k) % i;
i+= 1
return r+1
cases= int(sys.stdin.readline())
current= 0
while current < cases:
current += 1
n = int(sys.stdin.readline())
print remaining(n, 2)
aW1wb3J0IHN5cwoKZGVmIHJlbWFpbmluZyggbiwgayk6CiAgICByID0gMAogICAgaSA9IDIKICAgIHdoaWxlIGkgPD0gbjoKICAgICAgICByID0gKHIgKyBrKSAlIGk7CiAgICAgICAgaSs9IDEKICAgIHJldHVybiByKzEKICAgIApjYXNlcz0gaW50KHN5cy5zdGRpbi5yZWFkbGluZSgpKQpjdXJyZW50PSAwCndoaWxlIGN1cnJlbnQgPCBjYXNlczoKICAgIGN1cnJlbnQgICAgKz0gMQogICAgbiA9IGludChzeXMuc3RkaW4ucmVhZGxpbmUoKSkKICAgIHByaW50IHJlbWFpbmluZyhuLCAyKSA=