#include <bits/stdc++.h>
#define pii pair<long long,int>
#define ll long long
using namespace std;

int n;
ll ans;
int main()
{
    freopen("rgame.inp","r",stdin);
    freopen("rgame.out","w",stdout);
    int t;
    cin >> t;
    while (t--)
    {
        map <ll,int> M;
        cin >> n;
        for (int i=1; i<=n; i++)
        {
            ll x;
            cin >> x;
            M[x]++;
        }
        map <ll, int> :: reverse_iterator it;
        /*for (it = M.rbegin(); it != M.rend(); it++)
            clog <<it->first << "=>" << it->second << "\n";*/
        vector <pii> seg;
        for (it = M.rbegin(); it != M.rend(); it++)
            if (it->second > 1)
            {
                seg.push_back(pii(it->first,it->second));
                if (it -> second > 3) break;
            }
        ans = -1;
        if (seg.size() > 0)
        {
            if (seg[0].second > 3)
                ans = seg[0].first * seg[0].first;
            else if (seg.size() > 1)
                ans = seg[0].first * seg[1].first;
        }
        cout << ans << '\n';
    }

    return 0;
}
