Problem 13

Prime Divisor Spell

Math, Dynamic Programming

Problem Statement

In the enchanted land of Algebria, magic and numbers intertwine in mysterious ways. The Grand Magus has discovered that the secret to powerful spells lies in the prime factors of certain enchanted numbers. For this task, you are given an integer nn. Your mission is to compute the sum of all the unique prime divisors of nn. Formally, if
n=p1e1×p2e2××pkek,n = p_1^{e_1} \times p_2^{e_2} \times \cdots \times p_k^{e_k},
where p1,p2,,pkp_1, p_2, \dots, p_k are prime numbers, then you need to find
S=p1+p2++pk.S = p_1 + p_2 + \cdots + p_k.

Should nn have no prime divisors (i.e. when n=1n = 1), display 1-1 instead.

Input Format

  • The first line of input contains an integer TT, the number of test cases.
  • Each of the next TT lines contains a single integer nn.

It is guaranteed that:

  • 1T1051 \leq T \leq 10^5
  • 1n1061 \leq n \leq 10^6

Output Format

For each test case, output a single line containing the sum of the unique prime divisors of nn. If nn has no prime divisors, print 1-1.

Examples

Input

3
1
8
20

Output

-1
2
7

Input

2
15
14

Output

8
9

Code Editor

Language
Theme