//
// :author:   Polusummator
// :date:     14.09.2020 20:45
// :filename: 1406B.cpp
// :team:     Little PyPy Squad
//
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define Yes cout << "Yes" << el
#define No cout << "No" << el
#define fori(start, n) for (auto i = start; i < n; i++)
#define el '\n'
#define printa(array) for (auto i : array) cout << i << ' '; cout << endl;
#define printm(matrix) for (auto & i : matrix) {\
                            for (auto j : i) {\
                                cout << j << ' ';}\
                                cout << endl;}
#define cinar(arr) for (auto & i : arr) {\
                        cin >> i;}
#define cinma(matr) for (auto & i : matr) {\
                        cinar(i);}
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

bool comp (ll a, ll b) {
    return abs(a) <= abs(b);
}

int main() {
    fastIO;
    ll t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        cinar(a);
        sort(a.begin(), a.end());
        cout << max(max(a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5], a[n - 1] * a[n - 2] * a[n - 3] * a[1] * a[0]), a[n - 1] * a[0] * a[1] * a[2] * a[3]) << el;
//      BULLSHIT:
//        sort(a.begin(), a.end(), comp);
////        printa(a);
//        if (*max_element(a.begin(), a.end()) < 0) {
//            cout << a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5] * 1LL << el;
//            continue;
//        }
////        ll s = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5] * 1LL;
//
//            ll ma = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5] * 1LL, new_s;
//            for (ll j = 1; j <= 5; j++) {
//                new_s = 1;
//                for (ll notj = 1; notj <= 5; notj++)
//                    if (notj != j)
//                        new_s *= a[n - notj] * 1LL;
//
//                for (ll i = 0; i < n - 5; i++)
//                    if (new_s * a[i] * 1LL > ma)
//                        ma = new_s * a[i] * 1LL;
//            }
//            cout << ma << el;

    }
    return 0;
}


/
// :author:   Polusummator
// :date:     14.09.2020 20:45
// :filename: 1406B.cpp
// :team:     Little PyPy Squad
//
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define Yes cout << "Yes" << el
#define No cout << "No" << el
#define fori(start, n) for (auto i = start; i < n; i++)
#define el '\n'
#define printa(array) for (auto i : array) cout << i << ' '; cout << endl;
#define printm(matrix) for (auto & i : matrix) {\
                            for (auto j : i) {\
                                cout << j << ' ';}\
                                cout << endl;}
#define cinar(arr) for (auto & i : arr) {\
                        cin >> i;}
#define cinma(matr) for (auto & i : matr) {\
                        cinar(i);}
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

bool comp (ll a, ll b) {
    return abs(a) < abs(b);
}

int main() {
    fastIO;
    ll t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        cinar(a);
        sort(a.begin(), a.end(), comp);
//        printa(a);
//        if (*max_element(a.begin(), a.end()) < 0 || n == 5) {
//            cout << a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5] * 1LL << el;
//            continue;
//        }
//        ll s = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5] * 1LL;

        ll ma = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5] * 1LL, new_s;
        for (ll j = 1; j <= 5; j++) {
            new_s = 1;
            for (ll notj = 1; notj <= 5; notj++)
                if (notj != j)
                    new_s *= a[n - notj] * 1LL;

            for (ll i = 0; i < n - 5; i++)
                if (new_s * a[i] * 1LL > ma)
                    ma = new_s * a[i] * 1LL;
        }
        cout << ma << el;

    }
    return 0;
}


//
// :author:   Polusummator
// :date:     14.09.2020 20:45
// :filename: 1406B.cpp
// :team:     Little PyPy Squad
//
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define Yes cout << "Yes" << el
#define No cout << "No" << el
#define fori(start, n) for (auto i = start; i < n; i++)
#define el '\n'
#define printa(array) for (auto i : array) cout << i << ' '; cout << endl;
#define printm(matrix) for (auto & i : matrix) {\
                            for (auto j : i) {\
                                cout << j << ' ';}\
                                cout << endl;}
#define cinar(arr) for (auto & i : arr) {\
                        cin >> i;}
#define cinma(matr) for (auto & i : matr) {\
                        cinar(i);}
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

bool comp (ll a, ll b) {
    return abs(a) <= abs(b);
}

int main() {
    fastIO;
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        cinar(a);
        sort(a.begin(), a.end());
        cout << max(max(a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5], a[n - 1] * a[n - 2] * a[n - 3] * a[1] * a[0]), a[n - 1] * a[0] * a[1] * a[2] * a[3]) << el;
//      BULLSHIT:
//        sort(a.begin(), a.end(), comp);
////        printa(a);
//        if (*max_element(a.begin(), a.end()) < 0) {
//            cout << a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5] * 1LL << el;
//            continue;
//        }
////        ll s = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5] * 1LL;
//
//            ll ma = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5] * 1LL, new_s;
//            for (ll j = 1; j <= 5; j++) {
//                new_s = 1;
//                for (ll notj = 1; notj <= 5; notj++)
//                    if (notj != j)
//                        new_s *= a[n - notj] * 1LL;
//
//                for (ll i = 0; i < n - 5; i++)
//                    if (new_s * a[i] * 1LL > ma)
//                        ma = new_s * a[i] * 1LL;
//            }
//            cout << ma << el;

    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
bool err = 0;
int a[maxn];
unsigned long long ans = 1LL, ans2 = 1LL;
priority_queue<int> pq1, pq2;
priority_queue<int, vector<int>, greater<int>> qp1, qp2;

void solve1(){
	if(err) return;
	bool ok1 = 0, ok2 = 0;
		int a, b;
		if(pq1.size() >= 3){
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(pq2.size() >= 2){
			b = pq2.top();
			pq2.pop();
			int temp = pq2.top();
			pq2.push(b);
			b *= temp;
			ok2 = 1;
		}
		else if(!ok1){
			err = 1;
			return;
		}
		if(!ok1 || (ok1 && ok2 && (b > a))){
			pq2.pop();
			pq2.pop();
			ans *= b;
		}
		else{
			pq1.pop();
			pq1.pop();
			ans *= a;
		}
}

void solve2(){
	for(int i = 0; i < 5; i ++){
		if(qp1.empty()){ ans2 *= qp2.top(), qp2.pop(); continue;}
		else if(qp2.empty()) { ans2 *= qp1.top(), qp1.pop(); continue;}
		if(qp1.top() < qp2.top()){
			ans2 *= qp1.top();
			qp1.pop();
		}
		else{
			ans2 *= qp2.top();
			qp2.pop();
		}
	}
}

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		ans = ans2 = 1LL;
		while(!pq1.empty()) pq1.pop();
		while(!pq2.empty()) pq2.pop();
		while(!qp1.empty()) qp1.pop();
		while(!qp2.empty()) qp2.pop();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0LL){
				pq1.push(a[i]);
				qp1.push(a[i]);
			}
			else pq2.push(-a[i]), qp2.push(-a[i]);
		}
		solve1();
		solve1();
		solve2();
		if(pq1.size() >= 1 && !err) cout << ans * pq1.top() << "\n";
		else if(ans2 == 0) cout << 0 << "\n";
		else cout << "-" << ans2 << "\n";
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn], ans = 1LL, ans2 = 1LL;
priority_queue<int> pq1, pq2;
priority_queue<int, vector<int>, greater<int>> qp1, qp2;

void solve1(){
	bool ok1 = 0, ok2 = 0;
		int a, b;
		if(pq1.size() >= 3){
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(pq2.size() >= 2){
			b = pq2.top();
			pq2.pop();
			int temp = pq2.top();
			pq2.push(b);
			b *= temp;
			ok2 = 1;
		}
		else{
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(!ok1 || (ok1 && ok2 && (b > a))){
			pq2.pop();
			pq2.pop();
			ans *= b;
		}
		else if(!ok2 || (ok1 && ok2 && (a > b))){
			pq1.pop();
			pq1.pop();
			ans *= a;
		}
}

void solve2(){
	for(int i = 0; i < 5; i ++){
		if(qp1.empty()){ ans2 *= qp2.top(), qp2.pop(); continue;}
		else if(qp2.empty()) { ans2 *= qp1.top(), qp1.pop(); continue;}
		if(qp1.top() < qp2.top()){
			ans2 *= qp1.top();
			qp1.pop();
		}
		else{
			ans2 *= qp2.top();
			qp2.pop();
		}
	}
}

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		ans = ans2 = 1;
		while(!pq1.empty()) pq1.pop();
		while(!pq2.empty()) pq2.pop();
		while(!qp1.empty()) qp1.pop();
		while(!qp2.empty()) qp2.pop();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				pq1.push(a[i]);
				qp1.push(a[i]);
			}
			else pq2.push(-a[i]), qp2.push(-a[i]);
		}
		solve1();
		solve1();
		solve2();
		if(pq1.size() >= 1) cout << ans * pq1.top() << "\n";
		else cout << -ans2 << "\n";
	}

}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn], ans = 1LL, ans2 = 1LL;
priority_queue<int> pq1, pq2;
priority_queue<int, vector<int>, greater<int>> qp1, qp2;

void solve1(){
	bool ok1 = 0, ok2 = 0;
		int a, b;
		if(pq1.size() >= 3){
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(pq2.size() >= 2){
			b = pq2.top();
			pq2.pop();
			int temp = pq2.top();
			pq2.push(b);
			b *= temp;
			ok2 = 1;
		}
		else{
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(!ok1 || (ok1 && ok2 && (b > a))){
			pq2.pop();
			pq2.pop();
			ans *= b;
		}
		else{
			pq1.pop();
			pq1.pop();
			ans *= a;
		}
}

void solve2(){
	for(int i = 0; i < 5; i ++){
		if(qp1.empty()){ ans2 *= qp2.top(), qp2.pop(); continue;}
		else if(qp2.empty()) { ans2 *= qp1.top(), qp1.pop(); continue;}
		if(qp1.top() < qp2.top()){
			ans2 *= qp1.top();
			qp1.pop();
		}
		else{
			ans2 *= qp2.top();
			qp2.pop();
		}
	}
}

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		ans = ans2 = 1LL;
		while(!pq1.empty()) pq1.pop();
		while(!pq2.empty()) pq2.pop();
		while(!qp1.empty()) qp1.pop();
		while(!qp2.empty()) qp2.pop();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				pq1.push(a[i]);
				qp1.push(a[i]);
			}
			else pq2.push(-a[i]), qp2.push(-a[i]);
		}
		solve1();
		solve1();
		solve2();
		if(pq1.size() >= 1) cout << ans * pq1.top() << "\n";
		else cout << -ans2 << "\n";
	}

}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
bool err = 0;
int a[maxn];
unsigned long long ans = 1LL, ans2 = 1LL;
priority_queue<int> pq1, pq2;
priority_queue<int, vector<int>, greater<int>> qp1, qp2;

void solve1(){
	if(err) return;
	bool ok1 = 0, ok2 = 0;
		int a, b;
		if(pq1.size() >= 3){
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(pq2.size() >= 2){
			b = pq2.top();
			pq2.pop();
			int temp = pq2.top();
			pq2.push(b);
			b *= temp;
			ok2 = 1;
		}
		else if(!ok1){
			err = 1;
			return;
		}
		if(!ok1 || (ok1 && ok2 && (b > a))){
			pq2.pop();
			pq2.pop();
			ans *= b;
		}
		else{
			pq1.pop();
			pq1.pop();
			ans *= a;
		}
}

void solve2(){
	for(int i = 0; i < 5; i ++){
		if(qp1.empty()){ ans2 *= qp2.top(), qp2.pop(); continue;}
		else if(qp2.empty()) { ans2 *= qp1.top(), qp1.pop(); continue;}
		if(qp1.top() < qp2.top()){
			ans2 *= qp1.top();
			qp1.pop();
		}
		else{
			ans2 *= qp2.top();
			qp2.pop();
		}
	}
}

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		ans = ans2 = 1LL;
		while(!pq1.empty()) pq1.pop();
		while(!pq2.empty()) pq2.pop();
		while(!qp1.empty()) qp1.pop();
		while(!qp2.empty()) qp2.pop();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0LL){
				pq1.push(a[i]);
				qp1.push(a[i]);
			}
			else pq2.push(-a[i]), qp2.push(-a[i]);
		}
		solve1();
		solve1();
		solve2();
		if(pq1.size() >= 1 && !err) cout << ans * pq1.top() << "\n";
		else cout << "-" << ans2 << "\n";
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
bool err = 0;
int a[maxn];
int ans = 1LL, ans2 = 1LL;
priority_queue<int> pq1, pq2;
priority_queue<int, vector<int>, greater<int>> qp1, qp2;

void solve1(){
	if(err) return;
	bool ok1 = 0, ok2 = 0;
		int a, b;
		if(pq1.size() >= 3){
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(pq2.size() >= 2){
			b = pq2.top();
			pq2.pop();
			int temp = pq2.top();
			pq2.push(b);
			b *= temp;
			ok2 = 1;
		}
		else if(!ok1){
			err = 1;
			return;
		}
		if(!ok1 || (ok1 && ok2 && (b > a))){
			pq2.pop();
			pq2.pop();
			ans *= b;
		}
		else if(!ok2 || (ok1 && ok2 && (a > b))){
			pq1.pop();
			pq1.pop();
			ans *= a;
		}
		else{
			int tem[3], tep[3];
			for(int i = 0; i < 3; i ++){
				tem[i] = pq1.top();
				pq1.pop();
			}
			for(int i = 0; i < 3; i ++){
				tep[i] = pq2.top();
				pq2.pop();
			}
			if(tem[2] * pq1.top() < tep[0] * tep[1]){
				for(int i = 0; i < 3; i ++) pq2.push(tep[i]);
				pq1.push(tem[2]);
				ans *= (tem[0] * tem[1]);
			}
			else{
				for(int i = 0; i < 3; i ++) pq1.push(tem[i]);
				pq2.push(tep[2]);
				ans *= (tep[0] * tep[1]);
			}
		}
}

void solve2(){
	for(int i = 0; i < 5; i ++){
		if(qp1.empty()){ ans2 *= qp2.top(); qp2.pop(); continue;}
		else if(qp2.empty()) { ans2 *= qp1.top(); qp1.pop(); continue;}
		if(qp1.top() < qp2.top()){
			ans2 *= qp1.top();
			qp1.pop();
		}
		else{
			ans2 *= qp2.top();
			qp2.pop();
		}
	}
}

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		ans = ans2 = 1LL;
		while(!pq1.empty()) pq1.pop();
		while(!pq2.empty()) pq2.pop();
		while(!qp1.empty()) qp1.pop();
		while(!qp2.empty()) qp2.pop();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0LL){
				pq1.push(a[i]);
				qp1.push(a[i]);
			}
			else pq2.push(-a[i]), qp2.push(-a[i]);
		}
		solve1();
		solve1();
		solve2();
		if(pq1.size() >= 1 && !err) cout << ans * pq1.top() << "\n";
		else cout << -ans2 << "\n";
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
bool err = 0;
int a[maxn], ans = 1LL, ans2 = 1LL;
priority_queue<int> pq1, pq2;
priority_queue<int, vector<int>, greater<int>> qp1, qp2;

void solve1(){
	bool ok1 = 0, ok2 = 0;
		int a, b;
		if(pq1.size() >= 3){
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(pq2.size() >= 2){
			b = pq2.top();
			pq2.pop();
			int temp = pq2.top();
			pq2.push(b);
			b *= temp;
			ok2 = 1;
		}
		else{
			err = 1;
		}
		if(!ok1 || (ok1 && ok2 && (b > a))){
			pq2.pop();
			pq2.pop();
			ans *= b;
		}
		else{
			pq1.pop();
			pq1.pop();
			ans *= a;
		}
}

void solve2(){
	for(int i = 0; i < 5; i ++){
		if(qp1.empty()){ ans2 *= qp2.top(), qp2.pop(); continue;}
		else if(qp2.empty()) { ans2 *= qp1.top(), qp1.pop(); continue;}
		if(qp1.top() < qp2.top()){
			ans2 *= qp1.top();
			qp1.pop();
		}
		else{
			ans2 *= qp2.top();
			qp2.pop();
		}
	}
}

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		ans = ans2 = 1LL;
		while(!pq1.empty()) pq1.pop();
		while(!pq2.empty()) pq2.pop();
		while(!qp1.empty()) qp1.pop();
		while(!qp2.empty()) qp2.pop();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				pq1.push(a[i]);
				qp1.push(a[i]);
			}
			else pq2.push(-a[i]), qp2.push(-a[i]);
		}
		solve1();
		solve1();
		solve2();
		if(pq1.size() >= 1 && !err) cout << ans * pq1.top() << "\n";
		else cout << -ans2 << "\n";
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn];
vector<int> vc1, vc2;

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		vc1.clear();
		vc2.clear();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				vc1.pb(a[i]);
			}
			else vc2.pb(-a[i]);
		}
		sort(all(vc1));
		sort(all(vc2));
		if( (n == 5 && ((int)vc1.size() % 2 == 0) ) || n == (int)vc2.size()){
			int ans = 1LL;
			for(int i = 1; i <= n; i ++) a[i] = abs(a[i]);
			sort(a + 1, a + n + 1);
			for(int i = 1; i <= 5; i ++) ans *= a[i];
			cout << -ans << "\n";
		}
		else{
			reverse(all(vc1));
			reverse(all(vc2));
			int a = 1LL, b = 1LL, c = 1LL;
			if(vc1.size() >= 5)
				for(int i = 0; i < 5; i ++) a *= vc1[i];

			if(vc1.size() >= 3 && vc2.size() >= 2){
				for(int i = 0; i < 3; i ++) b *= vc1[i];
				for(int i = 0; i < 2; i ++) b *= vc2[i];
			}

			if(vc1.size() >= 1 && vc2.size() >= 4){
				for(int i = 0; i < 1; i ++) c *= vc1[i];
				for(int i = 0; i < 4; i ++) c *= vc2[i];
			}
			a = max(max(a, b), c);
			cout << a << "\n";
		}
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn];
vector<int> vc1, vc2;

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		vc1.clear();
		vc2.clear();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				vc1.pb(a[i]);
			}
			else vc2.pb(-a[i]);
		}
		sort(all(vc1));
		sort(all(vc2));
		if(n == 5 || n == (int)vc2.size()){
			sort(a + 1, a + n + 1);
			int ans = 1LL;
			for(int i = 1; i <= n; i ++) a[i] = abs(a[i]);
			for(int i = 1; i <= 5; i ++) ans *= a[i];
			cout << -ans << "\n";
		}
		else{
			reverse(all(vc1));
			reverse(all(vc2));
			int a = 1LL, b = 1LL, c = 1LL;
			for(int i = 0; i < 5; i ++) a *= vc1[i];

			for(int i = 0; i < 3; i ++) b *= vc1[i];
			for(int i = 0; i < 2; i ++) b *= vc2[i];

			for(int i = 0; i < 1; i ++) c *= vc1[i];
			for(int i = 0; i < 4; i ++) c *= vc2[i];
			a = max(max(a, b), c);
			cout << a << "\n";
		}
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
bool err = 0;
int a[maxn], ans = 1LL, ans2 = 1LL;
priority_queue<int> pq1, pq2;
priority_queue<int, vector<int>, greater<int>> qp1, qp2;

void solve1(){
	if(err) return;
	bool ok1 = 0, ok2 = 0;
		int a, b;
		if(pq1.size() >= 3){
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(pq2.size() >= 2){
			b = pq2.top();
			pq2.pop();
			int temp = pq2.top();
			pq2.push(b);
			b *= temp;
			ok2 = 1;
		}
		else if(!ok1){
			err = 1;
			return;
		}
		if(!ok1 || (ok1 && ok2 && (b > a))){
			pq2.pop();
			pq2.pop();
			ans *= b;
		}
		else{
			pq1.pop();
			pq1.pop();
			ans *= a;
		}
}

void solve2(){
	for(int i = 0; i < 5; i ++){
		if(qp1.empty()){ ans2 *= qp2.top(), qp2.pop(); continue;}
		else if(qp2.empty()) { ans2 *= qp1.top(), qp1.pop(); continue;}
		if(qp1.top() < qp2.top()){
			ans2 *= qp1.top();
			qp1.pop();
		}
		else{
			ans2 *= qp2.top();
			qp2.pop();
		}
	}
}

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		ans = ans2 = 1LL;
		while(!pq1.empty()) pq1.pop();
		while(!pq2.empty()) pq2.pop();
		while(!qp1.empty()) qp1.pop();
		while(!qp2.empty()) qp2.pop();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				pq1.push(a[i]);
				qp1.push(a[i]);
			}
			else pq2.push(-a[i]), qp2.push(-a[i]);
		}
		solve1();
		solve1();
		solve2();
		if(pq1.size() >= 1 && !err) cout << ans * pq1.top() << "\n";
		else cout << -ans2 << "\n";
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn];
vector<int> vc1, vc2;

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		vc1.clear();
		vc2.clear();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] >= 0){
				vc1.pb(a[i]);
			}
			else vc2.pb(-a[i]);
		}
		sort(all(vc1));
		sort(all(vc2));
		if( (n == 5 && ((int)vc1.size() % 2 == 0) ) || n == (int)vc2.size()){
			int ans = 1LL;
			for(int i = 1; i <= n; i ++) a[i] = abs(a[i]);
			sort(a + 1, a + n + 1);
			for(int i = 1; i <= 5; i ++) ans *= a[i];
			cout << -ans << "\n";
		}
		else{
			reverse(all(vc1));
			reverse(all(vc2));
			int a = 1LL, b = 1LL, c = 1LL;
			int ans = -INF;
			if(vc1.size() >= 5)
				for(int i = 0; i < 5; i ++) a *= vc1[i], ans = a;

			if(vc1.size() >= 3 && vc2.size() >= 2){
				for(int i = 0; i < 3; i ++) b *= vc1[i];
				for(int i = 0; i < 2; i ++) b *= vc2[i];
				if(ans == -INF) ans = b;
				else ans = max(ans, a);
			}

			if(vc1.size() >= 1 && vc2.size() >= 4){
				for(int i = 0; i < 1; i ++) c *= vc1[i];
				for(int i = 0; i < 4; i ++) c *= vc2[i];
				if(ans == -INF) ans = c;
				else ans = max(ans, c);
			}
			a = max(max(a, b), c);
			cout << a << "\n";
		}
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn];
vector<int> vc1, vc2;

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		vc1.clear();
		vc2.clear();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] >= 0){
				vc1.pb(a[i]);
			}
			else vc2.pb(-a[i]);
		}
		sort(all(vc1));
		sort(all(vc2));
		if( (n == 5 && ((int)vc1.size() % 2 == 0) ) || n == (int)vc2.size()){
			int ans = 1LL;
			for(int i = 1; i <= n; i ++) a[i] = abs(a[i]);
			sort(a + 1, a + n + 1);
			for(int i = 1; i <= 5; i ++) ans *= a[i];
			cout << -ans << "\n";
		}
		else{
			reverse(all(vc1));
			reverse(all(vc2));
			int a = 1LL, b = 1LL, c = 1LL;
			int ans = -INF;
			if(vc1.size() >= 5)
				for(int i = 0; i < 5; i ++) a *= vc1[i], ans = a;

			if(vc1.size() >= 3 && vc2.size() >= 2){
				for(int i = 0; i < 3; i ++) b *= vc1[i];
				for(int i = 0; i < 2; i ++) b *= vc2[i];
				if(ans == -INF) ans = b;
				else ans = max(ans, b);
			}

			if(vc1.size() >= 1 && vc2.size() >= 4){
				for(int i = 0; i < 1; i ++) c *= vc1[i];
				for(int i = 0; i < 4; i ++) c *= vc2[i];
				if(ans == -INF) ans = c;
				else ans = max(ans, c);
			}
			cout << ans << "\n";
		}
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn];
vector<int> vc1, vc2;

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		vc1.clear();
		vc2.clear();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				vc1.pb(a[i]);
			}
			else vc2.pb(-a[i]);
		}
		sort(all(vc1));
		sort(all(vc2));
		if(n == 5 || n == (int)vc2.size()){
			sort(a + 1, a + n + 1);
			int ans = 1LL;
			for(int i = 1; i <= n; i ++) a[i] = abs(a[i]);
			for(int i = 1; i <= 5; i ++) ans *= a[i];
			cout << -ans << "\n";
		}
		else{
			reverse(all(vc1));
			reverse(all(vc2));
			int a = 1, b = 1, c = 1;
			for(int i = 0; i < 5; i ++) a *= vc1[i];

			for(int i = 0; i < 3; i ++) b *= vc1[i];
			for(int i = 0; i < 2; i ++) b *= vc2[i];

			for(int i = 0; i < 1; i ++) c *= vc1[i];
			for(int i = 0; i < 4; i ++) c *= vc2[i];
			a = max(max(a, b), c);
			cout << a << "\n";
		}
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn];
vector<int> vc1, vc2;

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		vc1.clear();
		vc2.clear();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] >= 0){
				vc1.pb(a[i]);
			}
			else vc2.pb(-a[i]);
		}
		sort(all(vc1));
		sort(all(vc2));
		if( (n == 5 && ((int)vc1.size() % 2 == 0) ) || n == (int)vc2.size()){
			int ans = 1LL;
			for(int i = 1; i <= n; i ++) a[i] = abs(a[i]);
			sort(a + 1, a + n + 1);
			for(int i = 1; i <= 5; i ++) ans *= a[i];
			cout << -ans << "\n";
		}
		else{
			reverse(all(vc1));
			reverse(all(vc2));
			int a = 1LL, b = 1LL, c = 1LL;
			int ans = -INF;
			if(vc1.size() >= 5)
				for(int i = 0; i < 5; i ++) a *= vc1[i], ans = a;

			if(vc1.size() >= 3 && vc2.size() >= 2){
				for(int i = 0; i < 3; i ++) b *= vc1[i];
				for(int i = 0; i < 2; i ++) b *= vc2[i];
				if(ans == -INF) ans = b;
				else ans = max(ans, a);
			}

			if(vc1.size() >= 1 && vc2.size() >= 4){
				for(int i = 0; i < 1; i ++) c *= vc1[i];
				for(int i = 0; i < 4; i ++) c *= vc2[i];
				if(ans == -INF) ans = c;
				else ans = max(ans, c);
			}
			cout << ans << "\n";
		}
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn], ans = 1LL, ans2 = 1LL;
priority_queue<int> pq1, pq2;
priority_queue<int, vector<int>, greater<int>> qp1, qp2;

void solve1(){
	bool ok1 = 0, ok2 = 0;
		int a, b;
		if(pq1.size() >= 3){
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(pq2.size() >= 2){
			b = pq2.top();
			pq2.pop();
			int temp = pq2.top();
			pq2.push(b);
			b *= temp;
			ok2 = 1;
		}
		else{
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(!ok1 || (ok1 && ok2 && (b > a))){
			pq2.pop();
			pq2.pop();
			ans *= b;
		}
		else if(!ok2 || (ok1 && ok2 && (a > b))){
			pq1.pop();
			pq1.pop();
			ans *= a;
		}
}

void solve2(){
	for(int i = 0; i < 5; i ++){
		if(qp1.empty()){ ans2 *= qp2.top(), qp2.pop(); continue;}
		else if(qp2.empty()) { ans2 *= qp1.top(), qp1.pop(); continue;}
		if(qp1.top() < qp2.top()){
			ans2 *= qp1.top();
			qp1.pop();
		}
		else{
			ans2 *= qp2.top();
			qp2.pop();
		}
	}
}

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		ans = ans2 = 1LL;
		while(!pq1.empty()) pq1.pop();
		while(!pq2.empty()) pq2.pop();
		while(!qp1.empty()) qp1.pop();
		while(!qp2.empty()) qp2.pop();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				pq1.push(a[i]);
				qp1.push(a[i]);
			}
			else pq2.push(-a[i]), qp2.push(-a[i]);
		}
		solve1();
		solve1();
		solve2();
		if(pq1.size() >= 1) cout << ans * pq1.top() << "\n";
		else cout << -ans2 << "\n";
	}

}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn];
vector<int> vc1, vc2;

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		vc1.clear();
		vc2.clear();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] >= 0){
				vc1.pb(a[i]);
			}
			else vc2.pb(-a[i]);
		}
		sort(all(vc1));
		sort(all(vc2));
		if( (n == 5 && ((int)vc1.size() % 2 == 0) ) || n == (int)vc2.size()){
			int ans = 1LL;
			for(int i = 1; i <= n; i ++) a[i] = abs(a[i]);
			sort(a + 1, a + n + 1);
			for(int i = 1; i <= 5; i ++) ans *= a[i];
			cout << -ans << "\n";
		}
		else{
			reverse(all(vc1));
			reverse(all(vc2));
			int a = 1LL, b = 1LL, c = 1LL;
			if(vc1.size() >= 5)
				for(int i = 0; i < 5; i ++) a *= vc1[i];

			if(vc1.size() >= 3 && vc2.size() >= 2){
				for(int i = 0; i < 3; i ++) b *= vc1[i];
				for(int i = 0; i < 2; i ++) b *= vc2[i];
			}

			if(vc1.size() >= 1 && vc2.size() >= 4){
				for(int i = 0; i < 1; i ++) c *= vc1[i];
				for(int i = 0; i < 4; i ++) c *= vc2[i];
			}
			a = max(max(a, b), c);
			cout << a << "\n";
		}
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn];
vector<int> vc1, vc2;

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		vc1.clear();
		vc2.clear();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				vc1.pb(a[i]);
			}
			else vc2.pb(-a[i]);
		}
		sort(all(vc1));
		sort(all(vc2));
		if(n == 5 || n == (int)vc2.size()){
			sort(a + 1, a + n + 1);
			int ans = 1LL;
			for(int i = 1; i <= n; i ++) a[i] = abs(a[i]);
			for(int i = 1; i <= 5; i ++) ans *= a[i];
			cout << -ans << "\n";
		}
		else{
			reverse(all(vc1));
			reverse(all(vc2));
			int a = 1LL, b = 1LL, c = 1LL;
			if(vc1.size() >= 5)
				for(int i = 0; i < 5; i ++) a *= vc1[i];

			if(vc1.size() >= 3 && vc2.size() >= 2){
				for(int i = 0; i < 3; i ++) b *= vc1[i];
				for(int i = 0; i < 2; i ++) b *= vc2[i];
			}

			if(vc1.size() >= 1 && vc2.size() >= 4){
				for(int i = 0; i < 1; i ++) c *= vc1[i];
				for(int i = 0; i < 4; i ++) c *= vc2[i];
			}
			a = max(max(a, b), c);
			cout << a << "\n";
		}
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
bool err = 0;
int a[maxn], ans = 1LL, ans2 = 1LL;
priority_queue<int> pq1, pq2;
priority_queue<int, vector<int>, greater<int>> qp1, qp2;

void solve1(){
	if(err) return;
	bool ok1 = 0, ok2 = 0;
		int a, b;
		if(pq1.size() >= 3){
			a = pq1.top();
			pq1.pop();
			int temp = pq1.top();
			pq1.push(a);
			a *= temp;
			ok1 = 1;
		}
		if(pq2.size() >= 2){
			b = pq2.top();
			pq2.pop();
			int temp = pq2.top();
			pq2.push(b);
			b *= temp;
			ok2 = 1;
		}
		else{
			err = 1;
			return;
		}
		if(!ok1 || (ok1 && ok2 && (b > a))){
			pq2.pop();
			pq2.pop();
			ans *= b;
		}
		else{
			pq1.pop();
			pq1.pop();
			ans *= a;
		}
}

void solve2(){
	for(int i = 0; i < 5; i ++){
		if(qp1.empty()){ ans2 *= qp2.top(), qp2.pop(); continue;}
		else if(qp2.empty()) { ans2 *= qp1.top(), qp1.pop(); continue;}
		if(qp1.top() < qp2.top()){
			ans2 *= qp1.top();
			qp1.pop();
		}
		else{
			ans2 *= qp2.top();
			qp2.pop();
		}
	}
}

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		ans = ans2 = 1LL;
		while(!pq1.empty()) pq1.pop();
		while(!pq2.empty()) pq2.pop();
		while(!qp1.empty()) qp1.pop();
		while(!qp2.empty()) qp2.pop();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				pq1.push(a[i]);
				qp1.push(a[i]);
			}
			else pq2.push(-a[i]), qp2.push(-a[i]);
		}
		solve1();
		solve1();
		solve2();
		if(pq1.size() >= 1 && !err) cout << ans * pq1.top() << "\n";
		else cout << -ans2 << "\n";
	}
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int a[maxn];
vector<int> vc1, vc2;

signed main(){
	loli;
	int t;
	cin >> t;
	while(t --){
		int n;
		vc1.clear();
		vc2.clear();
		cin >> n;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(a[i] > 0){
				vc1.pb(a[i]);
			}
			else vc2.pb(-a[i]);
		}
		sort(all(vc1));
		sort(all(vc2));
		if( (n == 5 && ((int)vc1.size() % 2 == 0) ) || n == (int)vc2.size()){
			sort(a + 1, a + n + 1);
			int ans = 1LL;
			for(int i = 1; i <= n; i ++) a[i] = abs(a[i]);
			for(int i = 1; i <= 5; i ++) ans *= a[i];
			cout << -ans << "\n";
		}
		else{
			reverse(all(vc1));
			reverse(all(vc2));
			int a = 1LL, b = 1LL, c = 1LL;
			if(vc1.size() >= 5)
				for(int i = 0; i < 5; i ++) a *= vc1[i];

			if(vc1.size() >= 3 && vc2.size() >= 2){
				for(int i = 0; i < 3; i ++) b *= vc1[i];
				for(int i = 0; i < 2; i ++) b *= vc2[i];
			}

			if(vc1.size() >= 1 && vc2.size() >= 4){
				for(int i = 0; i < 1; i ++) c *= vc1[i];
				for(int i = 0; i < 4; i ++) c *= vc2[i];
			}
			a = max(max(a, b), c);
			cout << a << "\n";
		}
	}
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(int i,int j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;int a[n+1];vector<int> p,ne;int ct=0;

ll ans=1;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
    /*if(a[i]>=0)
    p.pb(a[i]);
    else
    ne.pb(a[i]);*/
}
sort(a,a+n,fun);
for(int i=n-1;i>=n-5;i--)
ans*=a[i];
if(ans<0&&ct<n&&n>5)
{int mx=-3002;ll ans2=ans;
    for(int i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3002;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;int mn=3002;
    for(int i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3002;
    fl(i,0,n-5)
    {
        if(a[i]<=0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,ans2);
}if(z)
ans=max(0*1LL,ans);
cout<<ans<<"\n";
/*sort(p.begin(),p.end());
sort(ne.begin(),ne.end());

int nne=ne.size();int np=p.size();

if(np==0)
{
    fl(i,0,5)
    ans*=ne[i];
    cout<<ans<<"\n";return;
}
if(np<=2)
{
    fl(i,0,4)
    ans*=ne[i];
    cout<<ans*p[np-1]<<"\n";return;
}
if(np==3)
{
    //3p+2ne,1p+4ne
    ll ans1=1;
    fl(i,0,4)
    ans*=ne[i];

}*/
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
void my_ans_is()
{
int n;cin>>n;int a[n];
fl(i,0,n) cin>>a[i];
sort(a,a+n);ll ans=1;
if(a[n-1]<0)
for(int i=n-1;i>=n-5;i--)
ans*=a[i]*1LL;
else
if(a[n-1]==0)
ans=0LL;
else
if(a[n-1]>0)
{
    fl(i,0,5)
    ans*=a[n-i-1];
    ans=max(ans,a[n-1]*a[n-2]*a[n-3]*a[0]*a[1]*1LL);
    ans=max(ans,a[n-1]*a[0]*a[1]*a[2]*a[3]*1LL);
}
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(ll i,ll j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(0*1ll,ans);
    cout<<ans<<"\n";return;
}
for(ll i=n-1;i>=n-5;i--)
ans*=a[i];
if(ans<0&&n>5)
{ll mx=-3004;ll ans2=ans;
    for(ll i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3004;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;ll mn=3040;
    for(ll i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3004;
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,ans2);
}if(z)
ans=max(0*1ll,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(ll i,ll j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;ll zero=0;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(zero,ans);
    cout<<ans<<"\n";return;
}
for(ll i=n-1;i>=n-5;i--)
ans*=a[i];
ll an=ans;
if(n>5&&ans<0)
{ll mx=-3004;ll ans2=ans;int ct=0;
    for(ll i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    {mx=max(mx,a[i]);ct++;}
    if(ct)
    ans/=mx;
    mx=-3004;
    if(ct)
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        {mx=max(mx,a[i]);}
    }
    if(ct)
    ans*=mx;ll mn=3040;ct=0;
    for(ll i=n-1;i>=n-5;i--)                 //11
                                              //1 0 5 4 -4 3 1 1 0 -3 2      0 0 1 1 1 2 3 -3 -4 4 5
    if(a[i]>0)
    {mn=min(mn,a[i]);ct=1;}
    if(ct)
    ans2/=mn;
    mn=3004;
    if(ct)
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    if(ct)
    ans2*=mn;
    ans=max(ans,max(an,ans2));
}
if(z)
ans=max(zero,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
void my_ans_is()
{
int n;cin>>n;int a[n];
fl(i,0,n) cin>>a[i];
sort(a,a+n);ll ans;
if(a[n-1]<0)
for(int i=n-1;i>=n-5;i--)
ans*=a[i];
else
if(a[n-1]==0)
ans=0;
else
{
    fl(i,0,5)
    ans*=a[n-i-1];
    ans=max(ans,a[n-1]*a[n-2]*a[n-3]*a[0]*a[1]);
    ans=max(ans,a[n-1]*a[0]*a[1]*a[2]*a[3])
}
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(int i,int j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;int a[n+1];vector<int> p,ne;int ct=0;

ll ans=1;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
    /*if(a[i]>=0)
    p.pb(a[i]);
    else
    ne.pb(a[i]);*/
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(0*1LL,ans);
    cout<<ans<<"\n";return;
}
for(int i=n-1;i>=n-5;i--)
ans*=a[i];
if(ans<0&&ct<n&&n>5)
{int mx=-3002;ll ans2=ans;
    for(int i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3002;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;int mn=3002;
    for(int i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3002;
    fl(i,0,n-5)
    {
        if(a[i]<=0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,ans2);
}if(z)
ans=max(0*1LL,ans);
cout<<ans<<"\n";
/*sort(p.begin(),p.end());
sort(ne.begin(),ne.end());

int nne=ne.size();int np=p.size();

if(np==0)
{
    fl(i,0,5)
    ans*=ne[i];
    cout<<ans<<"\n";return;
}
if(np<=2)
{
    fl(i,0,4)
    ans*=ne[i];
    cout<<ans*p[np-1]<<"\n";return;
}
if(np==3)
{
    //3p+2ne,1p+4ne
    ll ans1=1;
    fl(i,0,4)
    ans*=ne[i];

}*/
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
void my_ans_is()
{
int n;cin>>n;int a[n];
fl(i,0,n) cin>>a[i];
sort(a,a+n);ll ans=1;
if(a[n-1]<0)
for(int i=n-1;i>=n-5;i--)
ans*=a[i]*1LL;
else
if(a[n-1]==0)
ans=0LL;
else
{
    fl(i,0,5)
    ans*=a[n-i-1];
    ans=max(ans,a[n-1]*a[n-2]*a[n-3]*a[0]*a[1]*1LL);
    ans=max(ans,a[n-1]*a[0]*a[1]*a[2]*a[3]*1LL);
}
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(ll i,ll j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;ll zero=0;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(zero,ans);
    cout<<ans<<"\n";return;
}
for(ll i=n-1;i>=n-5;i--)
ans*=a[i];
ll an=ans;
if(n>5)
{ll mx=-3004;ll ans2=ans;
    for(ll i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3004;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;ll mn=3040;
    for(ll i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3004;
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,max(an,ans2));
}
if(z)
ans=max(zero,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(ll i,ll j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(0*1ll,ans);
    cout<<ans<<"\n";return;
}
for(ll i=n-1;i>=n-5;i--)
ans*=a[i];
ll an=ans;
if(ans<0&&n>5)
{ll mx=-3004;ll ans2=ans;
    for(ll i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3004;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;ll mn=3040;
    for(ll i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3004;
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,max(an,ans2));
}if(z)
ans=max(0*1ll,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(int i,int j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(0*1LL,ans);
    cout<<ans<<"\n";return;
}
for(int i=n-1;i>=n-5;i--)
ans*=a[i];
if(ans<0&&n>5)
{ll mx=-3004;ll ans2=ans;
    for(int i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3004;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;ll mn=3040;
    for(int i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3004;
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,ans2);
}if(z)
ans=max(0*1LL,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(int i,int j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(0*1LL,ans);
    cout<<ans<<"\n";return;
}
for(int i=n-1;i>=n-5;i--)
ans*=a[i];
if(ans<0&&n>5)
{ll mx=-1e9;ll ans2=ans;
    for(int i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-1e9;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;ll mn=1e9;
    for(int i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=1e9;
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,ans2);
}if(z)
ans=max(0*1LL,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(ll i,ll j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(0*1ll,ans);
    cout<<ans<<"\n";return;
}
for(ll i=n-1;i>=n-5;i--)
ans*=a[i];
if(n>5)
{ll mx=-3004;ll ans2=ans;
    for(ll i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3004;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;ll mn=3040;
    for(ll i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3004;
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,ans2);
}if(z)
ans=max(0*1ll,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
//Accepted
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(ll i,ll j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;ll zero=0;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(zero,ans);
    cout<<ans<<"\n";return;
}
for(ll i=n-1;i>=n-5;i--)
ans*=a[i];
ll an=ans;
if(n>5&&ans<0)
{ll mx=-3004;ll ans2=ans;int ct=0;
    for(ll i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    {mx=max(mx,a[i]);ct++;}
    if(ct)
    ans/=mx;
    mx=-3004;
    if(ct)
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        {mx=max(mx,a[i]);}
    }
    if(ct)
    ans*=mx;ll mn=3040;ct=0;
    for(ll i=n-1;i>=n-5;i--)
    if(a[i]>0)
    {mn=min(mn,a[i]);ct=1;}
    if(ct)
    ans2/=mn;
    mn=3004;
    if(ct)
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    if(ct)
    ans2*=mn;
    ans=max(ans,max(an,ans2));
}
if(z)
ans=max(zero,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(int i,int j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;int a[n+1];vector<int> p,ne;int ct=0;

ll ans=1;

fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
    /*if(a[i]>=0)
    p.pb(a[i]);
    else
    ne.pb(a[i]);*/
}
sort(a,a+n,fun);
for(int i=n-1;i>=n-5;i--)
ans*=a[i];
if(ans<0&&ct<n&&n>5)
{int mx=-3002;ll ans2=ans;
    for(int i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3002;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;int mn=3002;
    for(int i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3002;
    fl(i,0,n-5)
    {
        if(a[i]<=0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,ans2);
}
cout<<ans<<"\n";
/*sort(p.begin(),p.end());
sort(ne.begin(),ne.end());

int nne=ne.size();int np=p.size();

if(np==0)
{
    fl(i,0,5)
    ans*=ne[i];
    cout<<ans<<"\n";return;
}
if(np<=2)
{
    fl(i,0,4)
    ans*=ne[i];
    cout<<ans*p[np-1]<<"\n";return;
}
if(np==3)
{
    //3p+2ne,1p+4ne
    ll ans1=1;
    fl(i,0,4)
    ans*=ne[i];

}*/
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
void my_ans_is()
{
int n;cin>>n;int a[n];
fl(i,0,n) cin>>a[i];
sort(a,a+n);ll ans=1;
if(a[n-1]<0)
for(int i=n-1;i>=n-5;i--)
ans*=a[i];
else
if(a[n-1]==0)
ans=0;
else
{
    fl(i,0,5)
    ans*=a[n-i-1];
    ans=max(ans,a[n-1]*a[n-2]*a[n-3]*a[0]*a[1]*1LL);
    ans=max(ans,a[n-1]*a[0]*a[1]*a[2]*a[3]*1LL);
}
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=1e5+5;
int a[N];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        sort(a+1,a+n+1);
        ll ans;
        if(a[n]<0){
            ans=1ll*a[n]*a[n-1]*a[n-2]*a[n-3]*a[n-4];
        }
        else if(a[n]==0){
            ans=0;
        }
        else if(a[n]>0){
            ans=1ll*a[n]*a[n-1]*a[n-2]*a[n-3]*a[n-4];
            ans=max(ans,1ll*a[n]*a[n-1]*a[n-2]*a[2]*a[1]);
            ans=max(ans,1ll*a[n]*a[4]*a[3]*a[2]*a[1]);
        }
        printf("%lld\n",ans);
    }
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(int i,int j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n||n==5)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(0*1LL,ans);
    cout<<ans<<"\n";return;
}
for(int i=n-1;i>=n-5;i--)
ans*=a[i];
if(ans<0&&n>5)
{ll mx=-1e9;ll ans2=ans;
    for(int i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-1e9;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;ll mn=1e9;
    for(int i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=1e9;
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,ans2);
}if(z)
ans=max(0*1LL,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(int i,int j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];vector<int> p,ne;int ct=0;

ll ans=1;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(0*1LL,ans);
    cout<<ans<<"\n";return;
}
for(int i=n-1;i>=n-5;i--)
ans*=a[i];
if(ans<0&&ct<n&&n>5)
{ll mx=-3002;ll ans2=ans;
    for(int i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3002;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;ll mn=3002;
    for(int i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3002;
    fl(i,0,n-5)
    {
        if(a[i]<=0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,ans2);
}if(z)
ans=max(0*1LL,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
void my_ans_is()
{
int n;cin>>n;int a[n];
fl(i,0,n) cin>>a[i];
sort(a,a+n);ll ans=1;
if(a[n-1]<0)
for(int i=n-1;i>=n-5;i--)
ans*=a[i]*1ll;
else
if(a[n-1]==0)
ans=0LL;
else
if(a[n-1]>0)
{
    fl(i,0,5)
    ans*=a[n-i-1];
    ans=max(ans,a[n-1]*a[n-2]*a[n-3]*a[0]*a[1]*1ll);
    ans=max(ans,a[n-1]*a[0]*a[1]*a[2]*a[3]*1ll);
}
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(ll i,ll j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;ll zero=0;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(zero,ans);
    cout<<ans<<"\n";return;
}
for(ll i=n-1;i>=n-5;i--)
ans*=a[i];
ll an=ans;
if(ans<0&&n>5)
{ll mx=-3004;ll ans2=ans;
    for(ll i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3004;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;ll mn=3040;
    for(ll i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3004;
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,max(an,ans2));
}
if(z)
ans=max(zero,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//    IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(ll i,ll j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;ll a[n+1];int ct=0;

ll ans=1;ll zero=0;
int z=0;
fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
if(a[i]==0)
z++;
}
sort(a,a+n,fun);
if(ct==n)
{
    fl(i,0,5)
    ans*=a[i];
    if(z)
    ans=max(zero,ans);
    cout<<ans<<"\n";return;
}
for(ll i=n-1;i>=n-5;i--)
ans*=a[i];
ll an=ans;
if(n>5&&ans<0)
{ll mx=-3004;ll ans2=ans;int ct=0;
    for(ll i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    {mx=max(mx,a[i]);ct++;}
    if(ct)
    ans/=mx;
    mx=-3004;
    if(ct)
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        {mx=max(mx,a[i]);}
    }
    if(ct)
    ans*=mx;ll mn=3040;ct=0;
    for(ll i=n-1;i>=n-5;i--)
    if(a[i]>0)
    {mn=min(mn,a[i]);ct=1;}
    if(ct)
    ans2/=mn;
    mn=3004;
    if(ct)
    fl(i,0,n-5)
    {
        if(a[i]<0)
        mn=min(mn,a[i]);
    }
    if(ct)
    ans2*=mn;
    ans=max(ans,max(an,ans2));
}
if(z)
ans=max(zero,ans);
cout<<ans<<"\n";
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad
#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define fl(i,a,b) for(ll i=a;i<b;i++)

#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)

#define pb push_back
#define ub upper_bound
#define lb lower_bound

bool prime[1000001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=1000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
        }
    }

}

ll biexp(ll x, ll y)
{
    ll res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;

        y = y>>1;
        x = x*x;
    }
    return res;
}
ll bemo(ll x, ll y, ll m)
{
    ll res = 1;

    x = x % m;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}
ll maxSubArraySum(ll a[], ll size)
{
    ll max_so_far = INT_MIN, max_ending_here = 0;

    for (ll i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
bool fun(int i,int j)
{
    return abs(i)<abs(j);
}
void my_ans_is()
{
int n;cin>>n;int a[n+1];vector<int> p,ne;int ct=0;

ll ans=1;

fl(i,0,n)
{cin>>a[i];
if(a[i]<=0)
ct++;
    /*if(a[i]>=0)
    p.pb(a[i]);
    else
    ne.pb(a[i]);*/
}
sort(a,a+n,fun);
for(int i=n-1;i>=n-5;i--)
ans*=a[i];
if(ans<0&&ct<n)
{int mx=-3002;ll ans2=ans;
    for(int i=n-1;i>=n-5;i--)                                         //-1 1 -1 -2 2 -3
    if(a[i]<0)
    mx=max(mx,a[i]);
    ans/=mx;
    mx=-3002;
    fl(i,0,n-5)
    {
        if(a[i]>=0)
        mx=max(mx,a[i]);
    }
    ans*=mx;int mn=3002;
    for(int i=n-1;i>=n-5;i--)
    if(a[i]>0)
    mn=min(mn,a[i]);
    ans2/=mn;
    mn=3002;
    fl(i,0,n-5)
    {
        if(a[i]<=0)
        mn=min(mn,a[i]);
    }
    ans2*=mn;
    ans=max(ans,ans2);
}
cout<<ans<<"\n";
/*sort(p.begin(),p.end());
sort(ne.begin(),ne.end());

int nne=ne.size();int np=p.size();

if(np==0)
{
    fl(i,0,5)
    ans*=ne[i];
    cout<<ans<<"\n";return;
}
if(np<=2)
{
    fl(i,0,4)
    ans*=ne[i];
    cout<<ans*p[np-1]<<"\n";return;
}
if(np==3)
{
    //3p+2ne,1p+4ne
    ll ans1=1;
    fl(i,0,4)
    ans*=ne[i];

}*/
}
int main()
{
	fst;
	t
	{
         my_ans_is();
        }
   return 0;
}


/*
*  Problem Link: https://codeforces.com/contest/1406/problem/B
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<int>

bool cmp(int a, int b) {
    return abs(a) < abs(b);
}
int main() {
    IOS
    // Code Here
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        vi a(n);

        int containsZero = false;
        int pos = 0;
        // Take Input
        for (int i=0; i < n; i++) {
            cin>>a[i];
            if (a[i] == 0) containsZero = true;
            if (a[i] > 0) pos++;
        }
        sort(a.begin(), a.end(), cmp);

        int r = n-1;
        ll prod = 1;

        if (pos == 0) {
            for (int i=0; i < 5; i++) {
                prod = prod*a[i];
            }
        } else {
            for (int c=0; c < 4; c++) {
               prod = prod*a[r--];
            }
            int l = r;
            bool findPos = prod >= 0;
            while (l >= 0) {
                if (!findPos && a[l] <= 0)  {
                    prod = prod*a[l];
                    break;
                } else if (findPos && a[l] >= 0) {
                    prod = prod*a[l];
                }
                l--;
            }
        }
        cout<<prod<<"\n";
    }
    return 0;
}

// -3 -2 -1 -1 1 2


/*
*  Problem Link: https://codeforces.com/contest/1406/problem/B
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<int>

int main() {
    IOS
    // Code Here
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        vi a(n);

        int negs = 0;
        int pos = 0;
        int containsZero = false;
        int maxNegIdx = -1;
        int maxNeg = INT_MAX;
        // Take Input
        for (int i=0; i < n; i++) {
            cin>>a[i];
            if (a[i] < 0) {
                negs++;
            }
            else if (a[i] > 0) pos++;
            else containsZero = true;
        }
        sort(a.begin(), a.end());

        ll res = 1;
        // If All Negatives or zero
        if (pos == 0) {
            if (containsZero) res = 0;
            else {
                int r = n-1;
                int c = 0;
                ll prod = 1;
                while (c < 5) {
                    c++;
                    prod = prod * a[r];
                    r--;
                }
                res = prod;
            }
        } else {
            if (negs == 0) {
                int i = n-1;
                int c = 0;
                ll prod = 1;
                while (c < 5) {
                    prod = prod * a[i];
                    i--;
                    c++;
                }
                res = prod;
            } else {
                int c = 0;
                int l = 0;
                int r = n - 1;
                ll prod = 1;
                while (c < 5 && negs >= 2) {
                    ll negProd = a[l]*a[l+1];
                    if (negProd > a[r]) {
                        prod = prod*negProd;
                        l += 2;
                        c += 2;
                        negs -= 2;
                    } else {
                        prod = prod*a[r];
                        r--;
                        c++;
                    }
                }
                while (c < 5) {
                    prod = prod*a[r];
                    r--;
                    c++;
                }
                res = prod;
            }
        }

        cout<<res<<"\n";

    }
    return 0;
}


/*
*  Problem Link: https://codeforces.com/contest/1406/problem/B
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<int>

int main() {
    IOS
    // Code Here
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        vi a(n);

        int containsZero = false;
        // Take Input
        for (int i=0; i < n; i++) {
            cin>>a[i];
            if (a[i] == 0) containsZero = true;
        }
        sort(a.begin(), a.end());

        ll res = 1;
        vi els;
        for (int i=0; i < n; i++) {
            if (i < 5 || n - i - 1 < n - 5) {
                els.push_back(a[i]);
            }
        }

        int l = els.size();
        ll prod = INT_MIN;
        if (containsZero) prod = 0;
        for (int i=0; i < l; i++) {
            if (i + 4 >= l) break;
            for (int j=i+1; j < l; j++) {
                if (j + 3 >= l) break;
                for (int k=j+1; k < l; k++) {
                    if (k + 2 >= l) break;
                    for (int m=k+1; m < l; m++) {
                        if (m + 1 >= l) break;
                        for (int o=m+1; o < l; o++) {
                            ll r = (long) els[i]*els[j]*els[k]*els[m]*els[o];
                            prod = max(prod, r);
                        }
                    }
                }
            }
        }

        cout<<prod<<"\n";

    }
    return 0;
}

// -3 -2 -1 -1 1 2


/*
*  Problem Link: https://codeforces.com/contest/1406/problem/B
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<int>

bool cmp(int a, int b) {
    return abs(a) < abs(b);
}
int main() {
    IOS
    // Code Here
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        vi a(n);

        int containsZero = false;
        int pos = 0;
        // Take Input
        for (int i=0; i < n; i++) {
            cin>>a[i];
            if (a[i] == 0) containsZero = true;
            if (a[i] > 0) pos++;
        }
        sort(a.begin(), a.end(), cmp);

        int r = n-1;
        ll prod = 1;

        if (pos == 0) {
            for (int i=0; i < 5; i++) {
                prod = prod*a[i];
            }
        } else {
            for (int c=0; c < 4; c++) {
               prod = prod*a[r--];
            }
            int l = r;
            bool findPos = prod >= 0;
            while (l >= 0) {
                if (!findPos && a[l] <= 0)  {
                    prod = prod*a[l];
                    break;
                } else if (findPos && a[l] >= 0) {
                    prod = prod*a[l];
                    break;
                }
                l--;
            }
        }
        cout<<prod<<"\n";
    }
    return 0;
}

// -3 -2 -1 -1 1 2


/*
*  Problem Link: https://codeforces.com/contest/1406/problem/B
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<int>

bool cmp(int a, int b) {
    return abs(a) < abs(b);
}
int main() {
    IOS
    // Code Here
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        vi a(n);

        int containsZero = false;
        int pos = 0;
        // Take Input
        for (int i=0; i < n; i++) {
            cin>>a[i];
            if (a[i] == 0) containsZero = true;
            if (a[i] > 0) pos++;
        }
        sort(a.begin(), a.end(), cmp);

        // for (int i=0; i < n; i++) cout<<a[i]<<" ";
        // cout<<endl;

        int r = n-1;
        ll prod = 1;

        if (pos == 0) {
            if (containsZero) {
                prod = 0;
            } else {
                for (int i=0; i < 5; i++) {
                    prod = prod*a[i];
                }
            }
        } else {
            for (int c=0; c < 5; c++) {
               prod = prod*a[r--];
            }
            int l = r;
            ll res = prod;
            while (l >= 0) {
                int c = a[l];
                for (int i = r+1; i < n; i++) {
                    if (a[i] != 0) {
                        ll x = (prod * c ) / a[i];
                        res = max(res, x);
                    }
                }
                l--;
            }
            prod = res;
        }
        cout<<prod<<"\n";
    }
    return 0;
}

// 0 5 -4 4 4 1 -3 3 3
// 0 1 3 -3 3 -4 4 4 5


/*
*  Problem Link: https://codeforces.com/contest/1406/problem/B
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<int>

bool cmp(int a, int b) {
    return abs(a) < abs(b);
}
int main() {
    IOS
    // Code Here
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        vi a(n);

        int containsZero = false;
        int pos = 0;
        // Take Input
        for (int i=0; i < n; i++) {
            cin>>a[i];
            if (a[i] == 0) containsZero = true;
            if (a[i] > 0) pos++;
        }
        sort(a.begin(), a.end(), cmp);

        for (int i=0; i < n; i++) cout<<a[i]<<" ";
        cout<<"\n";

        int r = n-1;
        ll prod = 1;

        if (pos == 0) {
            for (int i=0; i < 5; i++) {
                prod = prod*a[i];
            }
        } else {
            for (int c=0; c < 4; c++) {
               prod = prod*a[r--];
            }
            int l = r;
            bool findPos = prod >= 0;
            while (l >= 0) {
                ll p = prod;
                int c = a[l];
                for (int i = r+1; i < n; i++) {
                    ll x = prod * c / a[i];
                    p = max(p, x);
                }
                prod = max(p, prod);
                l--;
            }
        }
        cout<<prod<<"\n";
    }
    return 0;
}

// -3 -2 -1 -1 1 2


/*
*  Problem Link: https://codeforces.com/contest/1406/problem/B
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<int>

int main() {
    IOS
    // Code Here
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        vi a(n);

        int negs = 0;
        int pos = 0;
        int containsZero = false;
        int maxNegIdx = -1;
        int maxNeg = INT_MAX;
        // Take Input
        for (int i=0; i < n; i++) {
            cin>>a[i];
            if (a[i] < 0) {
                negs++;
            }
            else if (a[i] > 0) pos++;
            else containsZero = true;
        }
        sort(a.begin(), a.end());

        int res = 1;
        // If All Negatives or zero
        if (pos == 0) {
            if (containsZero) res = 0;
            else {
                int r = n-1;
                int c = 0;
                int prod = 1;
                while (c < 5) {
                    c++;
                    prod = prod * a[r];
                    r--;
                }
                res = prod;
            }
        } else {
            if (negs == 0) {
                int i = n-1;
                int c = 0;
                int prod = 1;
                while (c < 5) {
                    prod = prod * a[i];
                    i--;
                    c++;
                }
                res = prod;
            } else {
                int c = 0;
                int l = 0;
                int r = n - 1;
                int prod = 1;
                while (c < 5 && negs >= 2) {
                    int negProd = a[l]*a[l+1];
                    if (negProd > a[r]) {
                        prod = prod*negProd;
                        l += 2;
                        c += 2;
                        negs -= 2;
                    } else {
                        prod = prod*a[r];
                        r--;
                        c++;
                    }
                }
                while (c < 5) {
                    prod = prod*a[r];
                    r--;
                    c++;
                }
                res = prod;
            }
        }

        cout<<res<<"\n";

    }
    return 0;
}


/*
*  Problem Link: https://codeforces.com/contest/1406/problem/B
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<int>

int main() {
    IOS
    // Code Here
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        vi a(n);

        int negs = 0;
        int pos = 0;
        int containsZero = false;
        int maxNegIdx = -1;
        int maxNeg = INT_MAX;
        // Take Input
        for (int i=0; i < n; i++) {
            cin>>a[i];
            if (a[i] < 0) {
                negs++;
            }
            else if (a[i] > 0) pos++;
            else containsZero = true;
        }
        sort(a.begin(), a.end());

        ll res = 1;
        // If All Negatives or zero
        if (pos == 0) {
            if (containsZero) res = 0;
            else {
                int r = n-1;
                int c = 0;
                ll prod = 1;
                while (c < 5) {
                    c++;
                    prod = prod * a[r];
                    r--;
                }
                res = prod;
            }
        } else {
            if (negs == 0) {
                int i = n-1;
                int c = 0;
                ll prod = 1;
                while (c < 5) {
                    prod = prod * a[i];
                    i--;
                    c++;
                }
                res = prod;
            } else {
                int c = 0;
                int l = 0;
                int r = n - 1;
                ll prod = 1;
                while (c < 4) {
                    ll lProd = (ll) a[l]*a[l+1];
                    ll rProd = (ll) a[r]*a[r-1];
                    // cout<<l<<" "<<r<<endl;
                    if (lProd > rProd) {
                        prod = prod*lProd;
                        l += 2;
                        c+=2;
                    } else {
                        prod = prod*rProd;
                        r -= 2;
                        c += 2;
                    }
                }
                res = prod;
            }
        }

        cout<<res<<"\n";

    }
    return 0;
}