#include #include #include #include #include #include #include #include #include #include #include #define rf freopen("in.in", "r", stdin) #define wf freopen("out.out", "w", stdout) #define rep(i, s, n) for(int i=int(s); i<=int(n); ++i) using namespace std; const int mx = 1e5 + 10, mod = 1e9+7; map numOfSticksLen; int main() { //rf;// wf; ios::sync_with_stdio(0); int t; cin >> t; while(t--) { int n; numOfSticksLen.clear(); cin >> n; rep(i, 1, n) { int a; cin >> a; numOfSticksLen[a]++; } map::reverse_iterator rit = numOfSticksLen.rbegin(); int best=0, secondBest=0; while(rit != numOfSticksLen.rend() and (!best or !secondBest)) { if(rit->second >= 4) { if(!best) best = secondBest = rit->first; else secondBest = rit->first; break; } else if(rit->second >= 2 and !best) { best = rit->first; } else if(rit->second >=2 and !secondBest) { secondBest = rit->first; break; } rit++; } if(best and secondBest) cout << best*secondBest << endl; else cout << -1 << endl; } return 0; }