#include #include #include #include #include #include using namespace std; typedef long long LL; const int M=1000010; int T; vector v; vector pr; bool is[100100] = {false}; void init() { for(int i=2; i*i<=100000; i++) if(is[i] == false) for(int j=i+i; j<=100000; j+=i) is[j] = true; for(int i=2; i<=100000; i++) if(is[i] == false) pr.push_back(i); } void solve(int x) { int size = pr.size(); for(int i =0; i x) break; if(x % tmp == 0) { while(x%tmp == 0) { x/=tmp; v.push_back(tmp); } } } if(x!=1) v.push_back(x); } int main() { init(); cin>>T; int n; while(T--) { v.clear(); cin>>n; for(int i=1,t; i<=n; i++) { scanf("%d", &t); solve(t); } unique(v.begin(), v.end()); sort(v.begin(), v.end()); int size = v.size(); if(size < 2) { printf("-1\n"); continue; } LL tmp = (LL)v[0] * (LL)v[1]; cout<