for i in range(0, int(input())):
    c = int(input())

    l = False
    for j in range(1, c):
        s = 0

        for k in range(1, j + 1):
            if j % k == 0:
                s += k

        if s == c:
            print(j)
            l = True
            break

    if not l:
        print(-1)