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 = 'ddd = 0\r\n\r\n\r\ndef prime(n):\r\n    if n < 2:\r\n        return []\r\n    else:\r\n        n += 1\r\n        save = [True] * (n // 2)\r\n        for i in range(3, int(n ** 0.5) + 1, 2):\r\n\r\n            if save[i // 2]:\r\n                k = i * i\r\n                save[k // 2::i] = [False] * ((n - k - 1) // (2 * i) + 1)\r\n    return [2] + [2 * i + 1 for i in range(1, n // 2) if save[i]]\r\n\r\n\r\npp = prime(1000000)\r\n\r\n\r\ndef decom(x):\r\n    nns = 0\r\n    arrr = 0\r\n    answer = 1\r\n    while (x != 1):\r\n        nonlocal ddd\r\n        ddd += 1\r\n        while (x % pp[nns] == 0):\r\n            x = x / pp[nns]\r\n            arrr += 1\r\n        if arrr != 0:\r\n            answer = answer * (arrr + 1)\r\n            arrr = 0\r\n        nns += 1\r\n    return answer - 2\r\n\r\n\r\nrr = int(input())\r\np = 0\r\nfor i in range(rr):\r\n    n = int(input())\r\n    arr = list(map(int, input().split()))\r\n\r\n    arr.sort()\r\n\r\n    ss = arr[0] * arr[n - 1]\r\n    f = 0\r\n    for i in range(n):\r\n        ddd += 1\r\n        if arr[i] * arr[n - 1 - i] != ss:\r\n            f = 1\r\n            break\r\n    if decom(ss) != n:\r\n        f = 1\r\n    if f == 1:\r\n        print(-1)\r\n    else:\r\n        print(ss)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: