406586: GYM102448 E Everybody loves acai

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Everybody loves acaitime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Gabriel is a student from UFPE that loves acai (he really loves it). As he is really passionate about it, he became very picky about how much acai a perfect bowl should have.

A bowl is said to be perfect if the volume of acai in it is a perfect number.

A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself.

Gabriel decided to go to different restaurants and ask how much acai they have. Your task is to help him get the biggest perfect bowl on each of them or declare it is impossible.

Input

The first line of input contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^{6}$$$), the number of restaurants Gabriel will visit. Each of the next $$$n$$$ lines contains an integer $$$k_i$$$ ($$$1 \le k_i \le 2 \cdot 10^{6}$$$), the amount of acai the $$$i$$$-th restaurant has.

Output

Output should consist of $$$n$$$ lines. The $$$i$$$-th of them must contain an integer $$$a_i$$$, the biggest acai Gabriel can have at the $$$i$$$-th restaurant, or $$$-1$$$ if it's not possible to have a perfect acai.

ExampleInput
2
8
5
Output
6
-1
Note
  1. In the first example, the answer is $$$6$$$, since it's the biggest perfect number lower than or equal to $$$8$$$.
    • List of divisors of $$$8$$$, excluding itself => $$$[1, 2]$$$
    • List of divisors of $$$7$$$, excluding itself => $$$[1]$$$
    • List of divisors of $$$6$$$, excluding itself => $$$[1, 2, 3]$$$
  2. In the second example, the answer is $$$-1$$$, since we don't have any perfect number lower than or equal to $$$5$$$.
    • List of divisors of $$$5$$$, excluding itself => $$$[1]$$$
    • List of divisors of $$$4$$$, excluding itself => $$$[1, 2]$$$
    • List of divisors of $$$3$$$, excluding itself => $$$[1]$$$
    • List of divisors of $$$2$$$, excluding itself => $$$[1]$$$
    • List of divisors of $$$1$$$, excluding itself => $$$[]$$$

加入题单

上一题 下一题 算法标签: