For two integers $$$x$$$ and $$$y$$$ ($$$x,y\ge 2$$$), we will say that $$$x$$$ is a generator of $$$y$$$ if and only if $$$x$$$ can be transformed to $$$y$$$ by performing the following operation some number of times (possibly zero):
For example,
Now, Kevin gives you an array $$$a$$$ consisting of $$$n$$$ pairwise distinct integers ($$$a_i\ge 2$$$).
You have to find an integer $$$x\ge 2$$$ such that for each $$$1\le i\le n$$$, $$$x$$$ is a generator of $$$a_i$$$, or determine that such an integer does not exist.
Each test contains multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 10^5$$$) — the length of the array $$$a$$$.
The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$2\le a_i\le 4\cdot 10^5$$$) — the elements in the array $$$a$$$. It is guaranteed that the elements are pairwise distinct.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.
For each test case, output a single integer $$$x$$$ — the integer you found. Print $$$-1$$$ if there does not exist a valid $$$x$$$.
If there are multiple answers, you may output any of them.
438 9 1042 3 4 52147 15453 6 8 25 100000
2 -1 7 3
In the first test case, for $$$x=2$$$:
In the second test case, it can be proven that it is impossible to find a common generator of the four integers.
Name |
---|