def d(a):
    s = 0
    for i in range(1, a+1):
        if a % i == 0:
            s += i
    if s == 1:
        s = -1
    return(s)

n =int(input())
for _ in range(n):
    a = int(input())
    print(d(a))