import sys
def lucky( n, k ):
if n ==1:
return 1
else:
return ((lucky (n-1, k) + k-1) % n)+1
cases= int(sys.stdin.readline())
current= 0
while current < cases:
current += 1
n = int(sys.stdin.readline())
print lucky (n, 2)
aW1wb3J0IHN5cwoKZGVmIGx1Y2t5KCBuLCBrICk6CiAgICBpZiBuID09MToKICAgICAgICByZXR1cm4gMQogICAgZWxzZToKICAgICAgICByZXR1cm4gKChsdWNreSAobi0xLCBrKSArIGstMSkgJSBuKSsxCiAgICAgICAgCmNhc2VzPSBpbnQoc3lzLnN0ZGluLnJlYWRsaW5lKCkpCmN1cnJlbnQ9IDAKd2hpbGUgY3VycmVudCA8IGNhc2VzOgogICAgY3VycmVudAkrPSAxCiAgICBuID0gaW50KHN5cy5zdGRpbi5yZWFkbGluZSgpKQogICAgcHJpbnQgbHVja3kgKG4sIDIp