from sys import stdin

big = 10 ** 7 + 1
mem, ma, out = [1] * big, [-1] * big, []
for i in range(2, big):
    j = i
    while j < big:
        mem[j] += i
        j += i

for i in range(1, big):
    if mem[i] < big:
        ma[mem[i]] = i

for _ in range(int(input())):
    x = int(stdin.readline())
    out.append(mem[x])

print('\n'.join(map(str, out)))
