#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007
#define endl "\n"
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " ";
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
#define inf INT64_MAX
int32_t main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        arrinp(i, a, 0, n - 1);
        vector<int> neg, pos;
        bool flag = 0;
        bool zero = false;
        for(int x : a)
        {
            if(x > 0) flag = true;
            if(x == 0) zero = true;
            if(x >= 0) pos.push_back(x);
            else neg.push_back(x);
        }
        if(flag == false && zero == true)
        {
            outline(0);
            continue;
        }
        sortvectorrev(pos);
        sortvector(neg);
        int count = 0;
        vector<p> p1, p2;
        for(int i = 0; i < pos.size() - 1; i += 2)
        {
            if(i >= pos.size()) break;
            int prod = pos[i]*pos[i + 1];
            p1.push_back({prod, 0});
        }
        for(int i = 0; i < neg.size() - 1; i += 2)
        {
            if(i >= neg.size()) break;
            p2.push_back({neg[i]*neg[i + 1], 1});
        }
        sortvectorrev(p1);
        sortvectorrev(p2);
        int ans = INT_MIN;
        for(int i = 0; i < 3; i++)
        {
            for(int j = 0; j < 3; j++)
            {
                if(i + j == 2)
                {
                    int i1 = 0, i2 = 0;
                    int cur = 1;
                    int s = p1.size();
                    if(i > s) continue;
                    if(j > p2.size()) continue;
                    for(int k = 0; k < min(i, s); k++)
                    {
                        cur *= p1[k].first;
                        i1 += 2;
                    }
                    s = p2.size();
                    for(int k = 0; k < min(j, s); k++)
                    {
                        // out(p2[k].first)
                        cur *= p2[k].first;
                        // out(j)
                        // out(cur)
                        // out(i2)
                        // out(" ")
                        i2 += 2;
                    }
                    if(i1 < pos.size())
                    {
                        cur *= pos[i1];
                    }
                    else if(neg.size()%2 == 1 < neg.size())
                    {
                        // out("Here")
                        // out(neg[i2])
                        cur *= neg[neg.size() - 1];
                        // out(cur)
                    }
                    ans = max(ans, cur);
                }
            }
        }
        outline(ans)
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007
#define endl "\n"
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " ";
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
#define inf INT64_MAX
int32_t main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        arrinp(i, a, 0, n - 1);
        vector<int> neg, pos;
        bool flag = 0;
        bool zero = false;
        for(int x : a)
        {
            if(x > 0) flag = true;
            if(x == 0) zero = true;
            if(x >= 0) pos.push_back(x);
            else neg.push_back(x);
        }
        if(flag == false && zero == true)
        {
            outline(0);
            continue;
        }
        sortvectorrev(pos);
        sortvector(neg);
        int count = 0;
        int i1 = 0, i2 = 0;
        vector<p> all;
        for(int i = 0; i < pos.size() - 1; i += 2)
        {
            if(i >= pos.size()) break;
            int prod = pos[i]*pos[i + 1];
            all.push_back({prod, 0});
        }
        for(int i = 0; i < neg.size() - 1; i += 2)
        {
            if(i >= neg.size()) break;
            all.push_back({neg[i]*neg[i + 1], 1});
        }
        sortvectorrev(all);
        int ans = 1;
        for(int i = 0; i < 2; i++)
        {
            int x = all[i].first;
            if(all[i].second == 0) i1 += 2;
            else i2 += 2;
            // out(i1)
            // out(i2)
            // out(" ")
            ans *= x;
            count += 2;
        }
        if(i1 < pos.size())
        {
            ans *= pos[i1];
        }
        else if(i2 < neg.size())
        {
            ans *= neg[i2];
        }
        int ans1 = 1;
        count = 0;
        i1 = 0, i2 = 0;
        for(int i = 0; i < all.size(); i++)
        {
            if(count > 4) break;
            p pp  = all[i];
            if(pp.second == 1)
            {
                ans1 *= pp.first;
                i2 += 2;
            }
        }
        if(i1 < pos.size())
        {
            ans1 *= pos[i1];
        }
        else if(i2 < neg.size())
        {
            ans1 *= neg[i2];
        }
        outline(max(ans1, ans))
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007
#define endl "\n"
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " ";
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
#define inf INT64_MAX
int32_t main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        arrinp(i, a, 0, n - 1);
        vector<int> neg, pos;
        bool flag = 0;
        bool zero = false;
        for(int x : a)
        {
            if(x > 0) flag = true;
            if(x == 0) zero = true;
            if(x >= 0) pos.push_back(x);
            else neg.push_back(x);
        }
        if(!flag && zero == true)
        {
            outline(0);
            continue;
        }
        if(zero == true && pos.size() < 4)
        {
            outline(0);
            continue;
        }
        sortvectorrev(pos);
        sortvector(neg);
        int count = 0;
        int i1 = 0, i2 = 0;
        vector<int> all;
        // cerr << pos.size() << endl;
        for(int i = 0; i < pos.size() - 1; i += 2)
        {
            if(i >= pos.size()) break;
            int prod = pos[i]*pos[i + 1]; //*pos[i + 1];
            all.push_back(prod);
            i1 = i + 2;
        }
        cerr << "Hi" << endl;
        for(int i = 0; i < neg.size() - 1; i += 2)
        {
            if(i >= neg.size()) break;
            all.push_back(neg[i]*neg[i + 1]);
            i2 = i + 2;
        }
        sortvectorrev(all);
        int ans = 1;
        for(int i = 0; i < 2; i++)
        {
            int x = all[i];
            // out(x);
            ans *= x;
            count += 2;
        }
        if(i1 < pos.size())
        {
            ans *= pos[i1];
        }
        else if(i2 < neg.size())
        {
            ans *= neg[i2];
        }
        outline(ans)
    }
    return 0;
}


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    sort(v.rbegin(),v.rend());
    ll res=1;
    if(v[4]*v[3]<v[n-1]*v[n-2])res*=v[n-1]*v[n-2];
    else res*=v[4]*v[3];
    if(v[2]*v[1]<v[n-3]*v[n-4])res*=v[n-3]*v[n-4];
    else res*=v[2]*v[1];
    if(v[0]<v[n-5])res*=v[n-5];
    else  res*=v[0];
    cout<<res<<E;
   }
        return 0;
    }


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    ll res=-1e9;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                     res=max(res,v[i]*v[j]*v[k]*v[l]*v[p]);
                    }
                }
            }
        }
    }
    cout<<res<<E;
   }
        return 0;
    }


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    if(n>=10){
      sort(v.rbegin(),v.rend());
      vector<ll>sum;
      sum.push_back(v[0]);
      sum.push_back(v[1]);
      sum.push_back(v[2]);
      sum.push_back(v[3]);
      sum.push_back(v[4]);
      sum.push_back(v[n-1]);
      sum.push_back(v[n-2]);
      sum.push_back(v[n-3]);
      sum.push_back(v[n-4]);
      sum.push_back(v[n-5]);
     ll res=-1e18;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                            ll val=sum[i]*sum[j]*sum[k]*sum[l]*sum[p];
                     res=max(res,val);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
    else {
        ll res=-1e18;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                            ll val=v[i]*v[j]*v[k]*v[l]*v[p];
                     res=max(res,val);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
   }
        return 0;
    }


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    if(n>=10){
      sort(v.rbegin(),v.rend());
      vector<ll>sum;
      sum.push_back(v[0]);
      sum.push_back(v[1]);
      sum.push_back(v[2]);
      sum.push_back(v[3]);
      sum.push_back(v[4]);
      sum.push_back(v[n-1]);
      sum.push_back(v[n-2]);
      sum.push_back(v[n-3]);
      sum.push_back(v[n-4]);
      sum.push_back(v[n-5]);
     ll res=-1e18;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                     res=max(res,sum[i]*sum[j]*sum[k]*sum[l]*sum[p]);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
    else {
        ll res=-1e18;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                     res=max(res,v[i]*v[j]*v[k]*v[l]*v[p]);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
   }
        return 0;
    }


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    sort(v.rbegin(),v.rend());
    ll res=1;
    if(v[4]*v[3]<v[n-1]*v[n-2]){
            res*=v[n-1]*v[n-2];
    if(v[2]*v[1]<v[n-3]*v[n-4])res*=v[n-3]*v[n-4];
    else res*=v[2]*v[1];
    res*=v[0];
    }
    else res*=v[0]*v[1]*v[2]*v[3]*v[4];
    cout<<res<<E;
   }
        return 0;
    }


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    if(n>=10){
      sort(v.rbegin(),v.rend());
      vector<ll>sum;
      ll res=1,x=0;
      bool yes=0,yes1;
      for(I i=n-1;i>=n-4;i--){
          for(I j=x;j<4;j++){
            if(v[i]*v[i-1]>v[j]*v[j+1]){
              sum.push_back(i);
               sum.push_back(i-1);
                x=j+2;
                i--;
                break;
            }
            sum.push_back(j);
          }
      }
      loop(0,sum.size())res*=v[sum[i]];
    cout<<res<<E;
    }
    else {
        ll res=-1e9;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                     res=max(res,v[i]*v[j]*v[k]*v[l]*v[p]);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
   }
        return 0;
    }


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    if(n>=10){
      sort(v.rbegin(),v.rend());
      ll res=1,x=0;
      res*=v[0]*v[1]*v[2]*v[3]*v[4];
      cerr<<res<<E;
      bool yes=0,yes1;
      for(I i=n-1;i>=n-4;i--){
          for(I j=x;j<4;j++){
            if(v[i]*v[i-1]>v[j]*v[j+1]){
                res/=(v[j]*v[j+1]);
                res*=(v[i]*v[i-1]);
                x=j+1;
                i--;
                break;
            }
          }
      }
    cout<<res<<E;
    }
    else {
        ll res=-1e18;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                     res=max(res,v[i]*v[j]*v[k]*v[l]*v[p]);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
   }
        return 0;
    }


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    if(n>=10){
      sort(v.rbegin(),v.rend());
      vector<ll>sum;
      sum.push_back(v[0]);
      sum.push_back(v[1]);
      sum.push_back(v[2]);
      sum.push_back(v[3]);
      sum.push_back(v[4]);
      sum.push_back(v[n-1]);
      sum.push_back(v[n-2]);
      sum.push_back(v[n-3]);
      sum.push_back(v[n-4]);
      sum.push_back(v[n-5]);
     ll res=-1e9;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                     res=max(res,sum[i]*sum[j]*sum[k]*sum[l]*sum[p]);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
    else {
        ll res=-1e9;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                     res=max(res,v[i]*v[j]*v[k]*v[l]*v[p]);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
   }
        return 0;
    }


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    if(n>=10){
      sort(v.rbegin(),v.rend());
      vector<ll>sum;
      sum.push_back(v[0]);sum.push_back(v[1]);sum.push_back(v[2]);sum.push_back(v[3]);sum.push_back(v[4]);
      sum.push_back(v[n-1]);sum.push_back(v[n-2]);sum.push_back(v[n-3]);sum.push_back(v[n-4]);sum.push_back(v[n-5]);
     ll res=-1e18;
    for(I i=0;i<10;i++){
        for( I j=i+1;j<10;j++){
            for(I k=j+1;k<10;k++){
                for( I l=k+1;l<10;l++){
                    for(I p=l+1;p<10;p++){
                            ll val=sum[i]*sum[j]*sum[k]*sum[l]*sum[p];
                     res=max(res,val);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
    else {
        ll res=-1e18;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                            ll val=v[i]*v[j]*v[k]*v[l]*v[p];
                     res=max(res,val);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
   }
        return 0;
    }


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    sort(v.rbegin(),v.rend());
    ll res=-1e9;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                     res=max(res,v[i]*v[j]*v[k]*v[l]*v[p]);
                    }
                }
            }
        }
    }
    cout<<res<<E;
   }
        return 0;
    }


    #include <bits/stdc++.h>
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double  d;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef  int I;
    using namespace std;
    #define  E endl
    #define loop(a,n) for(int i=a;i<n;i++)
    #define loop1(a,n) for(int j=a;j<n;j++)
    #define loop_r(a,n) for(int i=n-1;i>=a;i--)
    #define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
    #define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
    #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    bool cmp(const pair<ll,ll> &a,const pair<ll,ll> &b)
    {
        return a.second < b.second;
    };
    struct compare
    {
        bool operator()(const int& l, const int& r)
        {
            return l > r;
        }
    };
    bool prime(int n)
    {
        if(n==2)
            return true;
        for(int i=2; i*i<=n; i++)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    bool pal(string s)
    {
        int j=s.size()-1;
        for(int i=0; i<s.size()/2; i++)
        {
            if(s[i]!=s[j])
            {
                return false;
            }
            j--;
        }
        return true;
    }
    ll MOD=1e9+7;
    ll fast_power(ll x, ll y)
    {
        if (y == 0)
            return 1;
        ll temp = fast_power(x, y / 2);
        //temp%=MOD;
        if (y % 2 != 0)
            temp = (temp*temp*x);
        else
            temp = (temp*temp);
        return temp;//%MOD
    }
    vector<I>v1;
    ll div(long long n)
    {
        long long square_root = (long long ) sqrt(n) + 1;
        int cou=0;
        v1.push_back(1);
        v1.push_back(n);
        for (int h = 2; h <= square_root; h++)
        {

            if (n % h == 0&&h*h!=n)
                cou+=2,v1.push_back(h),v1.push_back(n/h);
            else if (n % h == 0&&h*h==n)
                cou+=1,v1.push_back(h),v1.push_back(h);
        }
        return cou;
    }

    int main()
    {

        speed;
   ll t,n,x;
   cin>>t;
   while(t--){
    cin>>n;
    vector<ll>v;
    loop(0,n){
    cin>>x;
    v.push_back(x);
    }
    if(n>=10){
      sort(v.rbegin(),v.rend());
      ll res=1,x=0;
      res*=v[0]*v[1]*v[2]*v[3]*v[4];
      bool yes=0,yes1;
      for(I i=n-1;i>=n-4;i--){
          for(I j=x;j<4;j++){
            if(v[i]*v[i-1]>v[j]*v[j+1]){
                res/=(v[j]*v[j+1]);
                res*=(v[i]*v[i-1]);
                x=j+1;
                i--;
                break;
            }
          }
      }
    cout<<res<<E;
    }
    else {
        ll res=-1e9;
    for(I i=0;i<n;i++){
        for( I j=i+1;j<n;j++){
            for(I k=j+1;k<n;k++){
                for( I l=k+1;l<n;l++){
                    for(I p=l+1;p<n;p++){
                     res=max(res,v[i]*v[j]*v[k]*v[l]*v[p]);
                    }
                }
            }
        }
    }
    cout<<res<<E;
    }
   }
        return 0;
    }


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

void solve() {
	int n;
	cin >> n;
	vector<int> ss(n);
	for(int i = 0; i < n; i++)
		cin >> ss[i];
	vector<long long> pos, neg;
	for(int i = 0; i < n; i++)
		if(ss[i] > 0)
			pos.push_back(ss[i]);
		else if(ss[i] < 0)
			neg.push_back(ss[i]);
	sort(pos.begin(), pos.end());
	reverse(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	vector<long long> answer(5);
	int index = 0;
	int pos_index = 0;
	int neg_index = 0;
	if((int)pos.size() > 2 && (int)neg.size() >= 2) {
		while(pos_index + 2 < (int)pos.size() && neg_index + 1 < (int)neg.size() && index < 4) {
			if(pos[pos_index] * pos[pos_index + 1] >= neg[neg_index] * neg[neg_index + 1])
				answer[index] = pos[pos_index], answer[index + 1] = pos[pos_index + 1];
			else
				answer[index] = neg[neg_index], answer[index + 1] = neg[neg_index + 1];
			pos_index += 2, neg_index += 2;
		}
	}
	if((int)pos.size() <= 2 && !pos.empty())
		answer[index++] = pos[pos_index++];
	else
		while(index < 5 && pos_index < (int)pos.size())
			answer[index] = pos[pos_index], pos_index++, index++;
	while(index < 5 && neg_index < (int)neg.size())
		answer[index] = neg[neg_index], neg_index++, index++;
	long long answer_pro = answer[0] * answer[1] * answer[2] * answer[3] * answer[4];
	cout << answer_pro << endl;
}

int main() {
	int problems = 0;
	cin >> problems;
	while(problems--)
		solve();
	return 0;
}


//Looked at the editoral not the code
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

bool compare(int a, int b) {
	return abs(a) > abs(b);
}

void solve() {
	int n;
	cin >> n;
	vector<int> ss(n);
	int counter = 0;
	for(int i = 0; i < n; i++)
		cin >> ss[i], counter += ss[i] < 0;
	sort(ss.begin(), ss.end(), compare);
	long long product = 1;
	if(counter == n) {
		for(int i = n - 1; i > n - 6; i--)
			product *= ss[i];
		cout << product << endl;
	}
	else {
		long long answer = -9999999999999999;
		for(int i = 0; i < 5; i++) {
			product = 1;
			for(int j = 0; j < 5; j++)
				if(j != i)
					product *= ss[j];
			long long curr_answer = -9999999999999999;
			for(int j = 5; j < n; j++)
				curr_answer = max(curr_answer, product * ss[j]);
			answer = max(answer, curr_answer);
		}
		cout << answer << endl;
	}
}

int main() {
	int problems = 0;
	cin >> problems;
	while(problems--)
		solve();
	return 0;
}


//Looked at the editoral not the code
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

bool compare(int a, int b) {
	return abs(a) > abs(b);
}

void solve() {
	int n;
	cin >> n;
	vector<int> ss(n);
	for(int i = 0; i < n; i++)
		cin >> ss[i];
	sort(ss.begin(), ss.end(), compare);
	long long product = 1;
	for(int i = 0; i < 5; i++)
		product *= ss[i];
	if(product > 0 || n == 5)
		cout << product << endl;
	else {
		long long answer = -9999999999999999;
		for(int i = 0; i < 5; i++) {
			product = 1;
			for(int j = 0; j < 5; j++)
				if(j != i)
					product *= ss[j];
			long long curr_answer = -9999999999999999;
			for(int j = 5; j < n; j++)
				curr_answer = max(curr_answer, product * ss[j]);
			answer = max(answer, curr_answer);
		}
		cout << answer << endl;
	}
}

int main() {
	int problems = 0;
	cin >> problems;
	while(problems--)
		solve();
	return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

vector<long long> pos, neg;

long long make(int pos_index = 0, int neg_index = 0, long long product = 1, int counter = 0, int state = 1) {
	if(counter == 5)
		return product;
	if(state == 1 && pos_index >= (int)pos.size())
		return -9999999999999999;
	if(state == 0 && neg_index >= (int)neg.size())
		return -9999999999999999;
	long long ret;
	if(counter == 4 && state == 0 && product > 0)
		return ret = make(pos_index + state, neg_index + !state, product * neg[(int)neg.size() - 1], counter + 1, 0);
	if(state)
		product *= pos[pos_index];
	else
		product *= neg[neg_index];
	long long ret1 = make(pos_index + state, neg_index + !state, product, counter + 1, 0);
	long long ret2 = make(pos_index + state, neg_index + !state, product, counter + 1, 1);
	return ret = max(ret1, ret2);
}
void solve() {
	pos.clear();
	neg.clear();
	int n;
	cin >> n;
	vector<int> ss(n);
	for(int i = 0; i < n; i++)
		cin >> ss[i];
	for(int i = 0; i < n; i++)
		if(ss[i] >= 0)
			pos.push_back(ss[i]);
		else if(ss[i] < 0)
			neg.push_back(ss[i]);
	sort(pos.begin(), pos.end());
	reverse(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	long long product = max(make(0, 0, 1, 0, 1), make(0, 0, 1, 0, 0));
	cout << product << endl;
}

int main() {
	int problems = 0;
	cin >> problems;
	while(problems--)
		solve();
	return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

void solve() {
	int n;
	cin >> n;
	vector<int> ss(n);
	for(int i = 0; i < n; i++)
		cin >> ss[i];
	vector<long long> pos, neg;
	for(int i = 0; i < n; i++)
		if(ss[i] > 0)
			pos.push_back(ss[i]);
		else if(ss[i] < 0)
			neg.push_back(ss[i]);
	sort(pos.begin(), pos.end());
	reverse(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	vector<long long> answer(5);
	int index = 0;
	int pos_index = 0;
	int neg_index = 0;
	if((int)pos.size() > 2 && (int)neg.size() >= 2) {
		while(pos_index + 2 < (int)pos.size() && neg_index + 1 < (int)neg.size() && index < 4) {
			if(pos[pos_index] * pos[pos_index + 1] >= neg[neg_index] * neg[neg_index + 1])
				answer[index] = pos[pos_index], answer[index + 1] = pos[pos_index + 1], pos_index += 2;
			else
				answer[index] = neg[neg_index], answer[index + 1] = neg[neg_index + 1], neg_index += 2;
			index += 2;

		}
	}

	if((int)pos.size() - pos_index <= 2)
		answer[index++] = pos[pos_index++];
	else
		while(index < 5 && pos_index < (int)pos.size())
			answer[index] = pos[pos_index], pos_index++, index++;
	while(index < 5 && neg_index < (int)neg.size())
		answer[index] = neg[neg_index], neg_index++, index++;
	long long answer_pro = answer[0] * answer[1] * answer[2] * answer[3] * answer[4];
	cout << answer_pro << endl;
}

int main() {
	int problems = 0;
	cin >> problems;
	while(problems--)
		solve();
	return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

void solve() {
	int n;
	cin >> n;
	vector<int> ss(n);
	for(int i = 0; i < n; i++)
		cin >> ss[i];
	vector<long long> pos, neg;
	for(int i = 0; i < n; i++)
		if(ss[i] > 0)
			pos.push_back(ss[i]);
		else if(ss[i] < 0)
			neg.push_back(ss[i]);
	sort(pos.begin(), pos.end());
	reverse(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	vector<long long> answer(5);
	int index = 0;
	int pos_index = 0;
	int neg_index = 0;
	if((int)pos.size() > 2 && (int)neg.size() >= 2) {
		while(pos_index + 2 < (int)pos.size() && neg_index + 1 < (int)neg.size() && index < 4) {
			if(pos[pos_index] * pos[pos_index + 1] >= neg[neg_index] * neg[neg_index + 1])
				answer[index] = pos[pos_index], answer[index + 1] = pos[pos_index + 1], pos_index += 2;
			else
				answer[index] = neg[neg_index], answer[index + 1] = neg[neg_index + 1], neg_index += 2;
			index += 2;

		}
	}

	if((int)pos.size() - pos_index <= 2 && !pos.empty())
		answer[index++] = pos[pos_index++];
	else
		while(index < 5 && pos_index < (int)pos.size())
			answer[index] = pos[pos_index], pos_index++, index++;
	while(index < 5 && neg_index < (int)neg.size())
		answer[index] = neg[neg_index], neg_index++, index++;
	long long answer_pro = answer[0] * answer[1] * answer[2] * answer[3] * answer[4];
	cout << answer_pro << endl;
}

int main() {
	int problems = 0;
	cin >> problems;
	while(problems--)
		solve();
	return 0;
}


//Looked at the editoral not the code
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

bool compare(int a, int b) {
	return abs(a) > abs(b);
}

void solve() {
	int n;
	cin >> n;
	vector<int> ss(n);
	int counter = 0;
	for(int i = 0; i < n; i++)
		cin >> ss[i], counter += ss[i] < 0;
	sort(ss.begin(), ss.end(), compare);
	long long product = 1;
	if(counter == n) {
		for(int i = n - 1; i > n - 6; i--)
			product *= ss[i];
		cout << product << endl;
	}
	else {
		long long answer = -999999999999999999;
		for(int j = 0; j < 5; j++)
			product *= ss[j];
		answer = max(answer, product);
		for(int i = 0; i < 5; i++) {
			product = 1;
			for(int j = 0; j < 5; j++)
				if(j != i)
					product *= ss[j];
			long long curr_answer = -999999999999999999;
			for(int j = 5; j < n; j++)
				curr_answer = max(curr_answer, product * ss[j]);
			answer = max(answer, curr_answer);
		}
		cout << answer << endl;
	}
}

int main() {
	int problems = 0;
	cin >> problems;
	while(problems--)
		solve();
	return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

void solve() {
	int n;
	cin >> n;
	vector<int> ss(n);
	for(int i = 0; i < n; i++)
		cin >> ss[i];
	vector<long long> pos, neg;
	for(int i = 0; i < n; i++)
		if(ss[i] > 0)
			pos.push_back(ss[i]);
		else if(ss[i] < 0)
			neg.push_back(ss[i]);
	sort(pos.begin(), pos.end());
	reverse(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	vector<long long> answer(5);
	int index = 0;
	int pos_index = 0;
	int neg_index = 0;
	if((int)pos.size() > 2 && (int)neg.size() >= 2) {
		while(pos_index + 2 < (int)pos.size() && neg_index + 1 < (int)neg.size() && index < 4) {
			if(pos[pos_index] * pos[pos_index + 1] >= neg[neg_index] * neg[neg_index + 1])
				answer[index] = pos[pos_index], answer[index + 1] = pos[pos_index + 1], pos_index += 2;
			else
				answer[index] = neg[neg_index], answer[index + 1] = neg[neg_index + 1], neg_index += 2;
			index += 2;

		}
	}
	if((int)pos.size() <= 2 && !pos.empty())
		answer[index++] = pos[pos_index++];
	else
		while(index < 5 && pos_index < (int)pos.size())
			answer[index] = pos[pos_index], pos_index++, index++;
	while(index < 5 && neg_index < (int)neg.size())
		answer[index] = neg[neg_index], neg_index++, index++;
	long long answer_pro = answer[0] * answer[1] * answer[2] * answer[3] * answer[4];
	cout << answer_pro << endl;
}

int main() {
	int problems = 0;
	cin >> problems;
	while(problems--)
		solve();
	return 0;
}


//Looked at the editoral not the code
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

bool compare(int a, int b) {
	return abs(a) > abs(b);
}

void solve() {
	int n;
	cin >> n;
	vector<int> ss(n);
	int counter = 0;
	for(int i = 0; i < n; i++)
		cin >> ss[i], counter += ss[i] < 0;
	sort(ss.begin(), ss.end(), compare);
	long long product = 1;
	if(counter == n) {
		for(int i = n - 1; i > n - 6; i--)
			product *= ss[i];
		cout << product << endl;
	}
	else {
		long long answer = -9999999999999999;
		for(int j = 0; j < 5; j++)
			product *= ss[j];
		answer = max(answer, product);
		for(int i = 0; i < 5; i++) {
			product = 1;
			for(int j = 0; j < 5; j++)
				if(j != i)
					product *= ss[j];
			long long curr_answer = -9999999999999999;
			for(int j = 5; j < n; j++)
				curr_answer = max(curr_answer, product * ss[j]);
			answer = max(answer, curr_answer);
		}
		cout << answer << endl;
	}
}

int main() {
	int problems = 0;
	cin >> problems;
	while(problems--)
		solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long getMax(vector<int> arr, int n, int total) {
    if (n > total)
        return INT_MIN;

    long long ans = 1;
    for(int i=3000; i>=1, n > 0; i--) {
        if (arr[i] > 0) {
            if (arr[i] >= n) {
                ans *= pow(-i, n);
                break;
            } else {
                n -= arr[i];
                ans *= pow(-i, arr[i]);
            }
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        if (n == 5) {
            int ans = 1, temp;
            for(int i=0; i<n; i++) {
                cin >> temp;
                ans *= temp;
            }
            cout << ans << "\n";
            continue;
        }

        vector<int> pos(3001, 0), neg(3001, 0);
        int temp, pcount = 0, ncount = 0;

        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0) {
                pos[temp]++;
                pcount++;
            }
            else {
                neg[(-1*temp)]++;
                ncount++;
            }
        }

        long long ans = 1LL;

        if (pcount == 0) {
            int count = 5;
            // ans would be negative
            // to maximise ans, choose 5 largest negative numbers

            for(int i=1; i<3001, count > 0; i++) {
                if (neg[i] > 0) {
                    if (neg[i] >= count) {
                        ans *= pow(-i, count);
                        break;
                    } else {
                        count -= neg[i];
                        ans *= pow(-i, neg[i]);
                    }
                }
            }
        } else {
            // there are some positive numbers
            // possible ways to choose -
            // 4n + 1p, 2n + 3p, 5p
            // ans is max of these

            long long first = getMax(neg, 4, ncount) * getMax(pos, 1, pcount) * -1;
            long long second = getMax(neg, 2, ncount) * getMax(pos, 3, pcount) * -1;
            long long third = getMax(pos, 5, pcount) * -1;

            ans = max(first, max(second, third));
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        int temp;
        vector<int> pos, neg;
        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0)
                pos.push_back(temp);
            else
                neg.push_back(temp);
        }

        sort(pos.begin(), pos.end(), greater<int>());
        sort(neg.begin(), neg.end());

        long long ans = INT_MIN;

        if (pos.size() == 0) {
            int s = neg.size()-1;
            ans = max(ans, 1LL* neg[s] * neg[s-1] * neg[s-2] * neg[s-3] * neg[s-4]);
        } else {
            for(int p=1; p<=5; p++) {
                int n = 5 - p;
                if (p > pos.size() || n > neg.size())
                    continue;

                long long sol = 1;
                for(int i=0; i<p; i++)
                    sol *= pos[i];

                for(int i=0; i<n; i++)
                    sol *= neg[i];

                ans = max(ans, sol);
            }
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long getMax(vector<int> arr, int n, int total) {
    if (n > total)
        return LONG_LONG_MIN;

    long long ans = 1;
    for(int i=3000; i>=1, n > 0; i--) {
        if (arr[i] > 0) {
            if (arr[i] >= n) {
                ans *= pow(-i, n);
                break;
            } else {
                n -= arr[i];
                ans *= pow(-i, arr[i]);
            }
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        if (n == 5) {
            int ans = 1, temp;
            for(int i=0; i<n; i++) {
                cin >> temp;
                ans *= temp;
            }
            cout << ans << "\n";
            continue;
        }

        vector<int> pos(3001, 0), neg(3001, 0);
        int temp, pcount = 0, ncount = 0;

        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0) {
                pos[temp]++;
                pcount++;
            }
            else {
                neg[(-1*temp)]++;
                ncount++;
            }
        }

        long long ans = 1LL;

        if (pcount == 0) {
            int count = 5;
            // ans would be negative
            // to maximise ans, choose 5 largest negative numbers

            for(int i=1; i<3001, count > 0; i++) {
                if (neg[i] > 0) {
                    if (neg[i] >= count) {
                        ans *= pow(-i, count);
                        break;
                    } else {
                        count -= neg[i];
                        ans *= pow(-i, neg[i]);
                    }
                }
            }
        } else {
            // there are some positive numbers
            // possible ways to choose -
            // 4n + 1p, 2n + 3p, 5p
            // ans is max of these

            long long first = getMax(neg, 4, ncount) * getMax(pos, 1, pcount) * -1;
            long long second = getMax(neg, 2, ncount) * getMax(pos, 3, pcount) * -1;
            long long third = getMax(pos, 5, pcount) * -1;

            ans = max(first, max(second, third));
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        int temp;
        vector<int> pos, neg;
        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0)
                pos.push_back(temp);
            else
                neg.push_back(temp);
        }

        sort(pos.begin(), pos.end(), greater<int>());
        sort(neg.begin(), neg.end());

        long long ans = LONG_LONG_MIN;

        if (pos.size() == 0) {
            int s = neg.size()-1;
            ans = max(ans, 1LL* neg[s] * neg[s-1] * neg[s-2] * neg[s-3] * neg[s-4]);
        } else {
            for(int p=1; p<=5; p++) {
                int n = 5 - p;
                if (p > pos.size() || n > neg.size())
                    continue;

                long long sol = 1;
                for(int i=0; i<p; i++)
                    sol *= pos[i];

                for(int i=0; i<n; i++)
                    sol *= neg[i];

                ans = max(ans, sol);
            }
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        int temp;
        vector<int> pos, neg;
        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0)
                pos.push_back(temp);
            else
                neg.push_back(temp);
        }

        sort(pos.begin(), pos.end(), greater<int>());
        sort(neg.begin(), neg.end());

        int ans = INT_MIN;

        if (pos.size() == 0) {
            int s = neg.size()-1;
            ans = neg[s] * neg[s-1] * neg[s-2] * neg[s-3] * neg[s-4];
        } else {
            for(int p=1; p<=5; p++) {
                int n = 5 - p;
                if (p > pos.size() || n > neg.size())
                    continue;

                int sol = 1;
                for(int i=0; i<p; i++)
                    sol *= pos[i];

                for(int i=0; i<n; i++)
                    sol *= neg[i];

                ans = max(ans, sol);
            }
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int getMax(vector<int> arr, int n, int total) {
    if (n > total)
        return INT_MIN;

    int ans = 1;
    for(int i=3000; i>=1, n > 0; i--) {
        if (arr[i] > 0) {
            n -= arr[i];
            while(arr[i]--)
                ans *= (-1*i);
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        if (n == 5) {
            int ans = 1, temp;
            for(int i=0; i<n; i++) {
                cin >> temp;
                ans *= temp;
            }
            cout << ans << "\n";
            continue;
        }

        vector<int> pos(3001, 0), neg(3001, 0);
        int temp, pcount = 0, ncount = 0;

        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0) {
                pos[temp]
                ++;
                pcount++;
            }
            else {
                neg[(-1*temp)]++;
                ncount++;
            }
        }

        int ans = 1;

        if (pcount == 0) {
            int count = 5;
            // ans would be negative
            // to maximise ans, choose 5 largest negative numbers

            for(int i=1; i<3001, count > 0; i++) {
                if (neg[i] > 0) {
                    count -= neg[i];
                    while(neg[i]--)
                        ans *= (-1*i);
                }
            }
        } else {
            // there are some positive numbers
            // possible ways to choose -
            // 4n + 1p, 2n + 3p, 5p
            // ans is max of these

            int first = getMax(neg, 4, ncount) * getMax(pos, 1, pcount) * -1;
            int second = getMax(neg, 2, ncount) * getMax(pos, 3, pcount) * -1;
            int third = getMax(pos, 5, pcount) * -1;

            ans = max(first, max(second, third));
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        int temp;
        vector<int> pos, neg;
        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0)
                pos.push_back(temp);
            else
                neg.push_back(temp);
        }

        sort(pos.begin(), pos.end(), greater<int>());
        sort(neg.begin(), neg.end());

        long long ans = INT_MIN;

        if (pos.size() == 0) {
            int s = neg.size()-1;
            ans = max(ans, 1LL* neg[s] * neg[s-1] * neg[s-2] * neg[s-3] * neg[s-4]);
        } else {
            for(int p=1; p<=5; p++) {
                int n = 5 - p;
                if (p > pos.size() || n > neg.size())
                    continue;

                long long sol = 1;
                for(int i=0; i<p; i++)
                    sol *= pos[i];

                for(int i=0; i<n; i++)
                    sol *= neg[i];

                ans = max(ans, sol);
            }
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int getMax(vector<int> arr, int n, int total) {
    if (n > total)
        return INT_MIN;

    int ans = 1;
    for(int i=3000; i>=1, n > 0; i--) {
        if (arr[i] > 0) {
            n -= arr[i];
            while(arr[i]--)
                ans *= (-1*i);
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        if (n == 5) {
            int ans = 1, temp;
            for(int i=0; i<n; i++) {
                cin >> temp;
                ans *= temp;
            }
            cout << ans << "\n";
            continue;
        }

        vector<int> pos(3001, 0), neg(3001, 0);
        int temp, pcount = 0, ncount = 0;

        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0) {
                pos[temp]
                ++;
                pcount++;
            }
            else {
                neg[(-1*temp)]++;
                ncount++;
            }
        }

        int ans = 1;

        if (pcount == 0) {
            int count = 5;
            // ans would be negative
            // to maximise ans, choose 5 largest negative numbers

            for(int i=1; i<3001, count > 0; i++) {
                if (neg[i] > 0) {
                    count -= neg[i];
                    while(neg[i]--)
                        ans *= (-1*i);
                }
            }
        } else {
            // there are some positive numbers
            // possible ways to choose -
            // 4n + 1p, 2n + 3p, 5p
            // ans is max of these

            int first = getMax(neg, 4, ncount) * getMax(pos, 1, pcount) * -1;
            int second = getMax(neg, 2, ncount) * getMax(pos, 3, pcount) * -1;
            int third = getMax(pos, 5, pcount);

            ans = max(first, max(second, third));
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int getMax(vector<int> arr, int n, int total) {
    if (n > total)
        return INT_MIN;

    int ans = 1;
    for(int i=3000; i>=1, n > 0; i--) {
        if (arr[i] > 0) {
            if (arr[i] >= n) {
                ans *= pow(-i, n);
                break;
            } else {
                n -= arr[i];
                ans *= pow(-i, arr[i]);
            }
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        if (n == 5) {
            int ans = 1, temp;
            for(int i=0; i<n; i++) {
                cin >> temp;
                ans *= temp;
            }
            cout << ans << "\n";
            continue;
        }

        vector<int> pos(3001, 0), neg(3001, 0);
        int temp, pcount = 0, ncount = 0;

        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0) {
                pos[temp]++;
                pcount++;
            }
            else {
                neg[(-1*temp)]++;
                ncount++;
            }
        }

        int ans = 1;

        if (pcount == 0) {
            int count = 5;
            // ans would be negative
            // to maximise ans, choose 5 largest negative numbers

            for(int i=1; i<3001, count > 0; i++) {
                if (neg[i] > 0) {
                    if (neg[i] >= count) {
                        ans *= pow(-i, count);
                        break;
                    } else {
                        count -= neg[i];
                        ans *= pow(-i, neg[i]);
                    }
                }
            }
        } else {
            // there are some positive numbers
            // possible ways to choose -
            // 4n + 1p, 2n + 3p, 5p
            // ans is max of these

            int first = getMax(neg, 4, ncount) * getMax(pos, 1, pcount) * -1;
            int second = getMax(neg, 2, ncount) * getMax(pos, 3, pcount) * -1;
            int third = getMax(pos, 5, pcount) * -1;

            ans = max(first, max(second, third));
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int getMax(vector<int> arr, int n, int total) {
    if (n > total)
        return INT_MIN;

    int ans = 1;
    for(int i=3000; i>=1, n > 0; i--) {
        if (arr[i] > 0) {
            arr[i] = min(arr[i], n);
            n -= arr[i];
            while(arr[i]--)
                ans *= (-1*i);
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        if (n == 5) {
            int ans = 1, temp;
            for(int i=0; i<n; i++) {
                cin >> temp;
                ans *= temp;
            }
            cout << ans << "\n";
            continue;
        }

        vector<int> pos(3001, 0), neg(3001, 0);
        int temp, pcount = 0, ncount = 0;

        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0) {
                pos[temp]++;
                pcount++;
            }
            else {
                neg[(-1*temp)]++;
                ncount++;
            }
        }

        int ans = 1;

        if (pcount == 0) {
            int count = 5;
            // ans would be negative
            // to maximise ans, choose 5 largest negative numbers

            for(int i=1; i<3001, count > 0; i++) {
                if (neg[i] > 0) {
                    neg[i] = min(neg[i], 5);
                    count -= neg[i];
                    while(neg[i]--)
                        ans *= (-1*i);
                }
            }
        } else {
            // there are some positive numbers
            // possible ways to choose -
            // 4n + 1p, 2n + 3p, 5p
            // ans is max of these

            int first = getMax(neg, 4, ncount) * getMax(pos, 1, pcount) * -1;
            int second = getMax(neg, 2, ncount) * getMax(pos, 3, pcount) * -1;
            int third = getMax(pos, 5, pcount) * -1;

            ans = max(first, max(second, third));
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int getMax(vector<int> arr, int n, int total) {
    if (n > total)
        return INT_MIN;

    int ans = 1;
    for(int i=3000; i>=1, n > 0; i--) {
        if (arr[i] > 0) {
            if (arr[i] >= n) {
                ans *= pow(-i, n);
                break;
            } else {
                n -= arr[i];
                ans *= pow(-i, arr[i]);
            }
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    freopen("input.txt", "r", stdin);

    int t;
    cin >> t;

    while(t--) {
        int n;
        cin >> n;

        if (n == 5) {
            int ans = 1, temp;
            for(int i=0; i<n; i++) {
                cin >> temp;
                ans *= temp;
            }
            cout << ans << "\n";
            continue;
        }

        vector<int> pos(3001, 0), neg(3001, 0);
        int temp, pcount = 0, ncount = 0;

        for(int i=0; i<n; i++) {
            cin >> temp;
            if (temp >= 0) {
                pos[temp]++;
                pcount++;
            }
            else {
                neg[(-1*temp)]++;
                ncount++;
            }
        }

        int ans = 1;

        if (pcount == 0) {
            int count = 5;
            // ans would be negative
            // to maximise ans, choose 5 largest negative numbers

            for(int i=1; i<3001, count > 0; i++) {
                if (neg[i] > 0) {
                    if (neg[i] >= count) {
                        ans *= pow(-i, count);
                        break;
                    } else {
                        count -= neg[i];
                        ans *= pow(-i, neg[i]);
                    }
                }
            }
        } else {
            // there are some positive numbers
            // possible ways to choose -
            // 4n + 1p, 2n + 3p, 5p
            // ans is max of these

            int first = getMax(neg, 4, ncount) * getMax(pos, 1, pcount) * -1;
            int second = getMax(neg, 2, ncount) * getMax(pos, 3, pcount) * -1;
            int third = getMax(pos, 5, pcount) * -1;

            ans = max(first, max(second, third));
        }
        cout << ans << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else
				ma++;

			if(mi_heap.size()<5)
			{
				mi_heap.push(arr[i]);
			}
			else
			{
				if(arr[i]>mi_heap.top())
				{
					mi_heap.pop();
					mi_heap.push(arr[i]);
				}
			}
			if(ma_heap.size()<5)
			{
				ma_heap.push(arr[i]);
			}
			else if(ma_heap.top()>arr[i])
			{
				ma_heap.pop();
				ma_heap.push(arr[i]);
			}

		}

		vector<int>mi_ele,ma_ele;
		while(!mi_heap.empty())
		{
			ma_ele.push_back(mi_heap.top());
			mi_heap.pop();
		}
		while(!ma_heap.empty())
		{
			mi_ele.push_back(ma_heap.top());
			ma_heap.pop();
		}

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=0;i<n;i++)
				sum*=ma_ele[i];
			cout<<sum<<endl;
			continue;
		}
		ll sum=0;

		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=3;i<5;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			cout<<max(sum,sum1)<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=1;i<5;i++)
				sum1*=mi_ele[i];
			for(int i=4;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=3;i<5;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			cout<<max(sum,sum1)<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0,zero=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else if(arr[i]>0)
				ma++;
			else
				zero++;

			if(mi_heap.size()<5)
			{
				mi_heap.push(arr[i]);
			}
			else
			{
				if(arr[i]>mi_heap.top())
				{
					mi_heap.pop();
					mi_heap.push(arr[i]);
				}
			}
			if(ma_heap.size()<5)
			{
				ma_heap.push(arr[i]);
			}
			else if(ma_heap.top()>arr[i])
			{
				ma_heap.pop();
				ma_heap.push(arr[i]);
			}

		}

		vector<ll>mi_ele,ma_ele;
		while(!mi_heap.empty())
		{
			ma_ele.push_back(mi_heap.top());
			mi_heap.pop();
		}
		while(!ma_heap.empty())
		{
			if(ma_heap.top()<0)
			mi_ele.push_back(ma_heap.top());
			ma_heap.pop();
		}
sort(mi_ele.begin(),mi_ele.end());
    sort(ma_ele.begin(),ma_ele.end());

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=0;i<n;i++)
				sum*=ma_ele[i];
			if(sum<0&&zero>0)sum=0;
			cout<<sum<<endl;
			continue;
		}
		ll sum=-1e19;

		// if(mi==n-1)
		// 	sum=1;
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=mi_ele[i];
			for(int i=4;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0,zero=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else if(arr[i]>0)
				ma++;
			else
				zero++;

			// if(mi_heap.size()<5)
			// {
			// 	mi_heap.push(arr[i]);
			// }
			// else
			// {
			// 	if(arr[i]>mi_heap.top())
			// 	{
			// 		mi_heap.pop();
			// 		mi_heap.push(arr[i]);
			// 	}
			// }
			// if(ma_heap.size()<5)
			// {
			// 	ma_heap.push(arr[i]);
			// }
			// else if(ma_heap.top()>arr[i])
			// {
			// 	ma_heap.pop();
			// 	ma_heap.push(arr[i]);
			// }

		}

// 		vector<ll>mi_ele,ma_ele;
// 		while(!mi_heap.empty())
// 		{
// 			ma_ele.push_back(mi_heap.top());
// 			mi_heap.pop();
// 		}
// 		while(!ma_heap.empty())
// 		{
// 			if(ma_heap.top()<0)
// 			mi_ele.push_back(ma_heap.top());
// 			ma_heap.pop();
// 		}
// sort(mi_ele.begin(),mi_ele.end());
//     sort(ma_ele.begin(),ma_ele.end());
		sort(arr,arr+n);

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=n-5;i<n;i++)
				sum*=arr[i];
			if(sum<0&&zero>0)sum=0;
			cout<<sum<<endl;
			continue;
		}
		ll sum=-1e17;

		// if(mi==n-1)
		// 	sum=1;
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=arr[i];
			for(int i=n-3;i<n;i++)
				sum1*=arr[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=n-5;i<n;i++)
				sum1*=arr[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=arr[i];
			for(int i=n-1;i<n;i++)
				sum1*=arr[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=arr[i];
			for(int i=n-3;i<n;i++)
				sum1*=arr[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=n-5;i<n;i++)
				sum1*=arr[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0,zero=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else if(arr[i]>0)
				ma++;
			else
				zero++;

			if(mi_heap.size()<5)
			{
				mi_heap.push(arr[i]);
			}
			else
			{
				if(arr[i]>mi_heap.top())
				{
					mi_heap.pop();
					mi_heap.push(arr[i]);
				}
			}
			if(ma_heap.size()<5)
			{
				ma_heap.push(arr[i]);
			}
			else if(ma_heap.top()>arr[i])
			{
				ma_heap.pop();
				ma_heap.push(arr[i]);
			}

		}

		vector<int>mi_ele,ma_ele;
		while(!mi_heap.empty())
		{
			ma_ele.push_back(mi_heap.top());
			mi_heap.pop();
		}
		while(!ma_heap.empty())
		{
			if(ma_heap.top()<0)
			mi_ele.push_back(ma_heap.top());
			ma_heap.pop();
		}

    sort(mi_ele.begin(),mi_ele.end());
    sort(ma_ele.begin(),ma_ele.end());
		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=0;i<n;i++)
				sum*=ma_ele[i];
			cout<<sum<<endl;
			continue;
		}
		ll sum=INT_MIN;

		// if(mi==n-1)
		// 	sum=1;
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=mi_ele[i];
			for(int i=4;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0,zero=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else if(arr[i]>0)
				ma++;
			else
				zero++;

			if(mi_heap.size()<5)
			{
				mi_heap.push(arr[i]);
			}
			else
			{
				if(arr[i]>mi_heap.top())
				{
					mi_heap.pop();
					mi_heap.push(arr[i]);
				}
			}
			if(ma_heap.size()<5)
			{
				ma_heap.push(arr[i]);
			}
			else if(ma_heap.top()>arr[i])
			{
				ma_heap.pop();
				ma_heap.push(arr[i]);
			}

		}

		vector<ll>mi_ele,ma_ele;
		while(!mi_heap.empty())
		{
			ma_ele.push_back(mi_heap.top());
			mi_heap.pop();
		}
		while(!ma_heap.empty())
		{
			if(ma_heap.top()<0)
			mi_ele.push_back(ma_heap.top());
			ma_heap.pop();
		}
sort(mi_ele.begin(),mi_ele.end());
    sort(ma_ele.begin(),ma_ele.end());

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=0;i<n;i++)
				sum*=ma_ele[i];
			if(sum<0&&zero>0)sum=0;
			cout<<sum<<endl;
			continue;
		}
		ll sum=-1e18;

		// if(mi==n-1)
		// 	sum=1;
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=mi_ele[i];
			for(int i=4;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll unsigned long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0,zero=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else if(arr[i]>0)
				ma++;
			else
				zero++;

			if(mi_heap.size()<5)
			{
				mi_heap.push(arr[i]);
			}
			else
			{
				if(arr[i]>mi_heap.top())
				{
					mi_heap.pop();
					mi_heap.push(arr[i]);
				}
			}
			if(ma_heap.size()<5)
			{
				ma_heap.push(arr[i]);
			}
			else if(ma_heap.top()>arr[i])
			{
				ma_heap.pop();
				ma_heap.push(arr[i]);
			}

		}

		vector<ll>mi_ele,ma_ele;
		while(!mi_heap.empty())
		{
			ma_ele.push_back(mi_heap.top());
			mi_heap.pop();
		}
		while(!ma_heap.empty())
		{
			if(ma_heap.top()<0)
			mi_ele.push_back(ma_heap.top());
			ma_heap.pop();
		}
sort(mi_ele.begin(),mi_ele.end());
    sort(ma_ele.begin(),ma_ele.end());

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=0;i<n;i++)
				sum*=ma_ele[i];
			if(sum<0&&zero>0)sum=0;
			cout<<sum<<endl;
			continue;
		}
		ll sum=-1e19;

		// if(mi==n-1)
		// 	sum=1;
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=mi_ele[i];
			for(int i=4;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else
				ma++;

			if(mi_heap.size()<5)
			{
				mi_heap.push(arr[i]);
			}
			else
			{
				if(arr[i]>mi_heap.top())
				{
					mi_heap.pop();
					mi_heap.push(arr[i]);
				}
			}
			if(ma_heap.size()<5)
			{
				ma_heap.push(arr[i]);
			}
			else if(ma_heap.top()>arr[i])
			{
				ma_heap.pop();
				ma_heap.push(arr[i]);
			}

		}

		vector<int>mi_ele,ma_ele;
		while(!mi_heap.empty())
		{
			ma_ele.push_back(mi_heap.top());
			mi_heap.pop();
		}
		while(!ma_heap.empty())
		{
			if(ma_heap.top()<0)
			mi_ele.push_back(ma_heap.top());
			ma_heap.pop();
		}

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=0;i<n;i++)
				sum*=ma_ele[i];
			cout<<sum<<endl;
			continue;
		}
		ll sum=0;

		sort(mi_ele.begin(),mi_ele.end());
		sort(ma_ele.begin(),ma_ele.end());
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			cout<<max(sum,sum1)<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=mi_ele[i];
			for(int i=4;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			cout<<max(sum,sum1)<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		ll arr[n];
		ll mi=0,ma=0,zero=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else if(arr[i]>0)
				ma++;
			else
				zero++;

			if(mi_heap.size()<5)
			{
				mi_heap.push(arr[i]);
			}
			else
			{
				if(arr[i]>mi_heap.top())
				{
					mi_heap.pop();
					mi_heap.push(arr[i]);
				}
			}
			if(ma_heap.size()<5)
			{
				ma_heap.push(arr[i]);
			}
			else if(ma_heap.top()>arr[i])
			{
				ma_heap.pop();
				ma_heap.push(arr[i]);
			}

		}

		vector<ll>mi_ele,ma_ele;
		while(!mi_heap.empty())
		{
			ma_ele.push_back(mi_heap.top());
			mi_heap.pop();
		}
		while(!ma_heap.empty())
		{
			if(ma_heap.top()<0)
			mi_ele.push_back(ma_heap.top());
			ma_heap.pop();
		}
sort(mi_ele.begin(),mi_ele.end());
    sort(ma_ele.begin(),ma_ele.end());

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=0;i<n;i++)
				sum*=ma_ele[i];
			if(sum<0&&zero>0)sum=0;
			cout<<sum<<endl;
			continue;
		}
		ll sum=-1e18;

		// if(mi==n-1)
		// 	sum=1;
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=mi_ele[i];
			for(int i=4;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];
// ll memo[100006][6];
ll solve(ll *arr,int n,int s,int e,ll p)
{
	if(e==5)
		return p;
	if(s>=n &&e!=5)return -1e16;
    // if(memo[s][e]!=-1e16)return memo[s][e];
// 	if(s<=n-1)
	 return max(solve(arr,n,s+1,e,p),solve(arr,n,s+1,e+1,p*arr[s]));
}

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){

		int n;
		cin>>n;
		ll arr[n];
		for(int i=0;i<n;i++)cin>>arr[i];
        // memset(memo,-1,sizeof memo);
        // for(int i=0;i<=n;i++)
        // for(int j=0;j<=5;j++)
        // memo[i][j]=-1e16;
		cout<<solve(arr,n,0,0,1)<<endl;

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0,zero=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else if(arr[i]>0)
				ma++;
			else
				zero++;

			// if(mi_heap.size()<5)
			// {
			// 	mi_heap.push(arr[i]);
			// }
			// else
			// {
			// 	if(arr[i]>mi_heap.top())
			// 	{
			// 		mi_heap.pop();
			// 		mi_heap.push(arr[i]);
			// 	}
			// }
			// if(ma_heap.size()<5)
			// {
			// 	ma_heap.push(arr[i]);
			// }
			// else if(ma_heap.top()>arr[i])
			// {
			// 	ma_heap.pop();
			// 	ma_heap.push(arr[i]);
			// }

		}

// 		vector<ll>mi_ele,ma_ele;
// 		while(!mi_heap.empty())
// 		{
// 			ma_ele.push_back(mi_heap.top());
// 			mi_heap.pop();
// 		}
// 		while(!ma_heap.empty())
// 		{
// 			if(ma_heap.top()<0)
// 			mi_ele.push_back(ma_heap.top());
// 			ma_heap.pop();
// 		}
// sort(mi_ele.begin(),mi_ele.end());
//     sort(ma_ele.begin(),ma_ele.end());
		sort(arr,arr+n);

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=n-5;i<n;i++)
				sum*=arr[i];
			if(sum<0&&zero>0)sum=0;
			cout<<sum<<endl;
			continue;
		}
		ll sum=-1e19;

		// if(mi==n-1)
		// 	sum=1;
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=arr[i];
			for(int i=n-3;i<n;i++)
				sum1*=arr[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=n-5;i<n;i++)
				sum1*=arr[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=arr[i];
			for(int i=n-1;i<n;i++)
				sum1*=arr[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=arr[i];
			for(int i=n-3;i<n;i++)
				sum1*=arr[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=n-5;i<n;i++)
				sum1*=arr[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0,zero=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else if(arr[i]>0)
				ma++;
			else
				zero++;

			if(mi_heap.size()<5)
			{
				mi_heap.push(arr[i]);
			}
			else
			{
				if(arr[i]>mi_heap.top())
				{
					mi_heap.pop();
					mi_heap.push(arr[i]);
				}
			}
			if(ma_heap.size()<5)
			{
				ma_heap.push(arr[i]);
			}
			else if(ma_heap.top()>arr[i])
			{
				ma_heap.pop();
				ma_heap.push(arr[i]);
			}

		}

		vector<int>mi_ele,ma_ele;
		while(!mi_heap.empty())
		{
			ma_ele.push_back(mi_heap.top());
			mi_heap.pop();
		}
		while(!ma_heap.empty())
		{
			if(ma_heap.top()<0)
			mi_ele.push_back(ma_heap.top());
			ma_heap.pop();
		}
sort(mi_ele.begin(),mi_ele.end());
    sort(ma_ele.begin(),ma_ele.end());

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=0;i<n;i++)
				sum*=ma_ele[i];
			if(sum<0&&zero>0)sum=0;
			cout<<sum<<endl;
			continue;
		}
		ll sum=INT_MIN;

		// if(mi==n-1)
		// 	sum=1;
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=mi_ele[i];
			for(int i=4;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0,zero=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else if(arr[i]>0)
				ma++;
			else
				zero++;

			if(mi_heap.size()<5)
			{
				mi_heap.push(arr[i]);
			}
			else
			{
				if(arr[i]>mi_heap.top())
				{
					mi_heap.pop();
					mi_heap.push(arr[i]);
				}
			}
			if(ma_heap.size()<5)
			{
				ma_heap.push(arr[i]);
			}
			else if(ma_heap.top()>arr[i])
			{
				ma_heap.pop();
				ma_heap.push(arr[i]);
			}

		}

		vector<ll>mi_ele,ma_ele;
		while(!mi_heap.empty())
		{
			ma_ele.push_back(mi_heap.top());
			mi_heap.pop();
		}
		while(!ma_heap.empty())
		{
			if(ma_heap.top()<0)
			mi_ele.push_back(ma_heap.top());
			ma_heap.pop();
		}
sort(mi_ele.begin(),mi_ele.end());
    sort(ma_ele.begin(),ma_ele.end());

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=0;i<n;i++)
				sum*=ma_ele[i];
			if(sum<0&&zero>0)sum=0;
			cout<<sum<<endl;
			continue;
		}
		ll sum=-1e17;

		// if(mi==n-1)
		// 	sum=1;
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=mi_ele[i];
			for(int i=4;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;
		}

	}

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define ip(arr) for(int i=0; i<arr.size(); i++) cin>>arr[i];

int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	cin>> t;

	while(t--){
		int n;
		cin>>n;
		int arr[n];
		ll mi=0,ma=0,zero=0;
		priority_queue<int>ma_heap;
		priority_queue<int,vector<int>,greater<int>>mi_heap;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]<0)
				mi++;
			else if(arr[i]>0)
				ma++;
			else
				zero++;

			if(mi_heap.size()<5)
			{
				mi_heap.push(arr[i]);
			}
			else
			{
				if(arr[i]>mi_heap.top())
				{
					mi_heap.pop();
					mi_heap.push(arr[i]);
				}
			}
			if(ma_heap.size()<5)
			{
				ma_heap.push(arr[i]);
			}
			else if(ma_heap.top()>arr[i])
			{
				ma_heap.pop();
				ma_heap.push(arr[i]);
			}

		}

		vector<int>mi_ele,ma_ele;
		while(!mi_heap.empty())
		{
			ma_ele.push_back(mi_heap.top());
			mi_heap.pop();
		}
		while(!ma_heap.empty())
		{
			if(ma_heap.top()<0)
			mi_ele.push_back(ma_heap.top());
			ma_heap.pop();
		}
sort(mi_ele.begin(),mi_ele.end());
    sort(ma_ele.begin(),ma_ele.end());

		if(n==5 || mi==0 || mi==1)
		{
			ll sum=1;
			for(int i=0;i<n;i++)
				sum*=ma_ele[i];
			if(sum<0&&zero>0)sum=0;
			cout<<sum<<endl;
			continue;
		}
		ll sum=-1e17;

		// if(mi==n-1)
		// 	sum=1;
		if(mi==2||mi==3)
		{
			ll sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);
			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;

		}

		if(mi>=4)
		{
			ll sum1=1;
			for(int i=0;i<4;i++)
				sum1*=mi_ele[i];
			for(int i=4;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			 sum1=1;
			for(int i=0;i<2;i++)
				sum1*=mi_ele[i];
			for(int i=2;i<5;i++)
				sum1*=ma_ele[i];
			sum=max(sum,sum1);

			sum1=1;
			for(int i=0;i<5;i++)
				sum1*=ma_ele[i];
			ll ans=max(sum,sum1);
			if(ans<0&&zero>0)ans=0;
			cout<<ans<<endl;
			continue;
		}

	}

}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int main()
{
	int t,a[maxn],n,flag,i,x,y,b[10],xx,yy;
	cin>>t;
	while(t--)
	{
		cin>>n;
		memset(b,0,sizeof(b));
		int ans=1;
		flag=0,x=0,y=0;
		for(i=1;i<=n;i++)
		{
			cin>>a[i];
			if(a[i]>0)
				y++;
		}
		sort(a+1,a+n+1);
		if(y==0)
		{
			for(i=n;i>=n-4;i--)
				ans*=a[i];
			printf("%d\n",ans);
			continue;
		}
		for(i=n-1;i>=1;i-=2)
		{
			if(a[i]>0&&a[i-1]>0)
			{
				b[flag]=a[i]*a[i-1];
				flag++;
			}
			else break;
			if(flag==2) break;
		}
		for(i=1;i<=n-1;i+=2)
		{
			if(a[i]<0&&a[i+1]<0)
			{
				b[flag]=a[i]*a[i+1];
				flag++;
			}
			else break;
			if(flag==4) break;
		}
		if(flag==1||flag==0)
		{
				for(i=n;i>=n-4;i--)
				ans*=a[i];
		}
		else if(flag==2) ans=b[0]*b[1]*a[n];
		else if(flag==3)
		{
			b[3]=-1;
			sort(b,b+4);
			ans=a[n]*b[3]*b[2];
		}
		else
		{
			sort(b,b+4);
			ans=a[n]*b[3]*b[2];
		}
		printf("%d\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int main()
{
	int t,a[maxn],n,flag,i,x,y,b[10],xx,yy;
	cin>>t;
	while(t--)
	{
		cin>>n;
		memset(b,0,sizeof(b));
		int ans=1;
		flag=0,x=0,y=0;
		for(i=1;i<=n;i++)
		{
			cin>>a[i];
			if(a[i]>0)
				y++;
		}
		sort(a+1,a+n+1);
		if(y==0)
		{
			for(i=n;i>=n-4;i--)
				ans*=a[i];
			printf("%d\n",ans);
			continue;
		}
		for(i=n-1;i>=1;i-=2)
		{
			if(a[i]>0&&a[i-1]>0)
			{
				b[flag]=a[i]*a[i-1];
				flag++;
			}
			else break;
			if(flag==2) break;
		}
		for(i=1;i<=n-1;i+=2)
		{
			if(a[i]<0&&a[i+1]<0)
			{
				b[flag]=a[i]*a[i+1];
				flag++;
			}
			else break;
			if(flag==4) break;
		}
		if(flag==1||flag==0)
			ans=0;
		else if(flag==2)
			ans=b[0]*b[1]*a[n];
		else if(flag==3)
		{
			sort(b,b+3);
			ans=a[n]*b[2]*b[1];
		}
		else
		{
			sort(b,b+4);
			ans=a[n]*b[3]*b[2];
		}
		printf("%d\n",ans);
	}
}