for _ in range(int(input())):
    c = int(input())
    flag = 0
    for i in range(1,1000):
        factor = [1]
        for j in range(2,i+1):
            if i%j==0:
                factor.append(j)
        if sum(factor)==c:
            print(i)
            flag=1
            break
        elif sum(factor)>c:
            break
        else:
            continue
    if flag==0:
        print(-1)