A prime number is number x which has only divisors as 1 and x itself.
Harsh is playing a game with his friends, where his friends give him a few numbers claiming that they are divisors of some number x but divisor 1 and the number x itself are not being given as divisors.
You need to help harsh find which number's divisors are given here.
His friends can also give him wrong set of divisors as a trick question for which no number exists.
Simply, We are given the divisors of a number x ( divisors except 1 and x itself ) , you have to print the number if only it is possible.
You have to answer t queries.
(USE LONG LONG TO PREVENT OVERFLOW)

-----Input:-----
- First line is T queires.
- Next are T queries.
- First line is N ( No of divisors except 1 and the number itself )
- Next line has N integers or basically the divisors.

-----Output:-----
Print the minimum possible x which has such divisors and print -1 if not possible.

-----Constraints-----
- 1<= T <= 30
- 1<= N <= 350
- 2<= Di <=10^6

-----Sample Input:-----
3
2
2 3
2
4 2
3
12 3 2

-----Sample Output:-----
6
8
-1

-----EXPLANATION:-----
Query 1 : Divisors of 6 are ( 1,2,3,6) Therefore, Divisors except 1 and the number 6 itself are ( 2 , 3). Thus, ans = 6.
Query 2 : Divisors of 8 are ( 1,2,4,8) Therefore, Divisors except 1 and the number 8 itself are ( 2 , 4). Thus, ans = 8.
Query 3 : There is no such number x with only ( 1,2,3,12,x ) as the divisors.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '# your code goes here\nimport math\ndef isp(n):\n\ti=2\n\tj=math.sqrt(n)\n\twhile i<=j:\n\t\tif n%i==0:\n\t\t\tbreak\n\t\ti+=1\n\treturn i>j\nt=int(input())\nwhile t>0:\n\tn=int(input())\n\tarr=list(map(int,input().split()))\n\tarr.sort()\n\tlst=[0]*1000001\n\tans=1\n\tk=0\n\tfor x in arr:\n\t\tif(isp(x)):\n\t\t\tif lst[x]==0:\n\t\t\t\tlst[x]=1\n\t\t\t\tans*=x\n\t\t\telse:\n\t\t\t    k+=1\n\t\t\t    break\n\t\telse:\n\t\t\ti=2\n\t\t\tj=math.sqrt(x)\n\t\t\twhile i<=j:\n\t\t\t\tif x%i==0:\n\t\t\t\t\tif lst[i]==0 or lst[x//i]==0:\n\t\t\t\t\t\tbreak\n\t\t\t\ti+=1\n\t\t\tif i<=j:\n\t\t\t\tk+=1\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t    if lst[x]==0:\n\t\t\t        lst[x]=1\n\t\t\t        ans*=x//math.gcd(ans,x)\n\t\t\t    else:\n\t\t\t\t    k+=1\n\t\t\t\t    break\n\t\t\t\t\n\tif k:\n\t\tprint(-1)\n\telse:\n\t\tif ans==arr[n-1]:\n\t\t\tp=ans\n\t\t\twhile p%arr[0]==0:\n\t\t\t\tp//=arr[0]\n\t\t\tif p==1:\n\t\t\t\tans*=arr[0]\n\t\t\t\tprint(ans)\n\t\t\telse:\n\t\t\t\tprint(-1)\n\t\telse:\n\t\t\tprint(ans)\n\tt-=1'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 16005972