#include <bits/stdc++.h>   using namespace std;   const int32_t INFint = 1e9;   const long long INFll = 1e18;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long arr[n];       for (long long i = 0; i < n; i++) cin >> arr[i];       ;       sort(arr, arr + n);       long long ans = arr[0] * arr[n - 1];       long long fact[100000];       long long index = 0;       for (long long i = 2; i <= sqrt(ans); i++) {         if (ans % i == 0) {           fact[index] = i;           index++;           if (i != ans / i) {             fact[index] = ans / i;             index++;           }         }       }       sort(fact, fact + index);       if (index != n) {         cout << -1 <<   n ;       } else {         long long flag = 0;         for (long long i = 0; i < n; i++) {           if (fact[i] != arr[i]) {             flag = 1;             break;           }         }         ans = flag ? -1 : ans;         cout << ans <<   n ;       }     }   }   