You are given an array of integers $a_1,a_2,\ldots,a_n$. Find the maximum possible value of $a_ia_ja_ka_la_t$ among all five indices $(i, j, k, l, t)$ ($i<j<k<l<t$).


-----Input-----

The input consists of multiple test cases. The first line contains an integer $t$ ($1\le t\le 2 \cdot 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($5\le n\le 10^5$) — the size of the array.

The second line of each test case contains $n$ integers $a_1,a_2,\ldots,a_n$ ($-3\times 10^3\le a_i\le 3\times 10^3$) — given array.

It's guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot 10^5$.


-----Output-----

For each test case, print one integer — the answer to the problem.


-----Example-----
Input
4
5
-1 -2 -3 -4 -5
6
-1 -2 -3 1 2 -1
6
-1 0 0 0 -1 -1
6
-9 -7 -5 -3 -2 1

Output
-120
12
0
945



-----Note-----

In the first test case, choosing $a_1,a_2,a_3,a_4,a_5$ is a best choice: $(-1)\cdot (-2) \cdot (-3)\cdot (-4)\cdot (-5)=-120$.

In the second test case, choosing $a_1,a_2,a_3,a_5,a_6$ is a best choice: $(-1)\cdot (-2) \cdot (-3)\cdot 2\cdot (-1)=12$.

In the third test case, choosing $a_1,a_2,a_3,a_4,a_5$ is a best choice: $(-1)\cdot 0\cdot 0\cdot 0\cdot (-1)=0$.

In the fourth test case, choosing $a_1,a_2,a_3,a_4,a_6$ is a best choice: $(-9)\cdot (-7) \cdot (-5)\cdot (-3)\cdot 1=945$.

Difficulty: EASY
Tags: Sorting

Implementation

Greedy algorithms

Complete search

Dynamic programming
Skill types: Dynamic programming

Sorting

Complete search

Greedy algorithms

Starter code:

Solutions:
from functools import reduce
import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = sorted(list(map(int, input().split())))
	if n == 5:
		ans = reduce(lambda x, y: x * y, a)
		print(ans)
	else:
		nl = []
		pl = []
		for i in range(4):
			if a[i] < 0:
				nl.append(a[i])
			else:
				break
		for i in range(n - 1, n - 6, -1):
			if a[i] > 0:
				pl.append(a[i])
			else:
				break
		if len(pl) == 0:
			ans = reduce(lambda x, y: x * y, a[n - 5:n])
		elif len(nl) < 2:
			ans = reduce(lambda x, y: x * y, a[n - 5:n])
		elif len(pl) >= 3 and len(nl) >= 2 or (len(pl) >= 1 and len(nl) >= 4) or len(pl) == 5:
			ans1 = ans2 = ans3 = 1
			if len(pl) == 5:
				ans1 = reduce(lambda x, y: x * y, pl)
			if len(pl) >= 3:
				pp = 1
				for i in range(3):
					pp = pp * pl[i]
				np = nl[0] * nl[1]
				ans2 = pp * np
			if len(nl) == 4:
				ans3 = reduce(lambda x, y: x * y, nl)
				ans3 = ans3 * pl[0]
			ans = max(ans1, ans2, ans3)
		else:
			ans = 0
		print(ans)


t = int(input())
for _ in range(0, t):
	n = int(input())
	list1 = [int(num) for num in input().split()]
	list1.sort()
	pro1 = 1
	for i in range(n - 1, n - 5 - 1, -1):
		pro1 = pro1 * list1[i]
	pro2 = list1[0] * list1[1] * list1[n - 1] * list1[n - 2] * list1[n - 3]
	pro3 = list1[0] * list1[1] * list1[2] * list1[3] * list1[n - 1]
	print(max([pro1, pro2, pro3]))


for k in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	m = -1e+18
	for i in range(6):
		c = 1
		for j in range(i):
			c *= a[j]
		for j in range(5 - i):
			c *= a[n - j - 1]
		m = max(m, c)
	print(m)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	print(max(a[0] * a[1] * a[2] * a[3] * a[-1], a[0] * a[1] * a[-1] * a[-2] * a[-3], a[-1] * a[-2] * a[-3] * a[-4] * a[-5]))


t = int(input())
for t in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	j = 0
	x_list = {}
	ps = []
	ne = []
	ze = []
	if l[n - 1] > 0:
		i = n - 1
		m = 1
		jk = []
		m *= l[i]
		i -= 1
		p = 0
		oiy = []
		qu = {}
		while p < 2 and j <= i:
			hgjg = []
			left = l[j] * l[j + 1]
			right = l[i] * l[i - 1]
			if left > right:
				m *= left
				j += 2
			else:
				m *= right
				i -= 2
			p += 1
		print(m)
	elif l[n - 1] < 0:
		m = 1
		kldf = []
		p = 0
		for j in range(n - 1, -1, -1):
			hguo = {}
			if p >= 5:
				break
			else:
				m *= l[j]
				p += 1
		print(m)
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	greatest5 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	smallest5 = a[0] * a[1] * a[2] * a[3] * a[4]
	arr = [greatest5, smallest5]
	larger = n - 1
	smaller = 0
	if a[0] != 0 and a[-1] != 0:
		if a[0] // abs(a[0]) != a[-1] // abs(a[-1]):
			arr.append(a[0] * a[1] * a[2] * a[3] * a[-1])
			arr.append(a[0] * a[1] * a[-1] * a[-2] * a[-3])
	print(max(arr))


t = int(input())
ans = list()
for i in range(t):
	ln = int(input())
	arr = list(map(int, input().split()))
	a = False
	for k in arr:
		if k > 0:
			a = True
			break
	if a:
		arr.sort(reverse=True, key=lambda x: abs(x))
		numbers = list()
		mn = 1
		last_p = 0
		last_n = 0
		for k in range(5):
			numbers.append(arr[k])
			mn *= arr[k]
			if arr[k] > 0:
				last_p = k
			else:
				last_n = k
		if mn >= 0:
			ans.append(mn)
		else:
			mp = 0
			mz = 0
			for k in range(5, len(arr)):
				if arr[k] > 0:
					mp = k
					break
			for k in range(5, len(arr)):
				if arr[k] < 0:
					mz = k
					break
			l = int(mn / arr[last_p]) * arr[mz]
			r = int(mn / arr[last_n]) * arr[mp]
			if mz > 0 and mp > 0 and (l >= r) or (mz > 0 and l >= r):
				mn = l
			elif mz > 0 and mp > 0 and (r >= l) or (mp > 0 and r >= l):
				mn = r
			elif mz > 0:
				mn = l
			elif mp > 0:
				mn = r
			elif 0 in arr:
				mn = 0
			ans.append(mn)
	else:
		arr.sort(reverse=True)
		mn = 1
		for l in range(5):
			mn *= arr[l]
		ans.append(mn)
for l in ans:
	print(l)


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	n = inin()
	A = lin()
	A.sort()
	x = A[n - 5] * A[n - 4] * A[n - 3] * A[n - 2] * A[n - 1]
	y = A[0] * A[1] * A[n - 3] * A[n - 2] * A[n - 1]
	z = A[0] * A[1] * A[2] * A[3] * A[n - 1]
	print(max(x, y, z))


def maxmul(alist):
	alist.sort()
	nlist = []
	plist = []
	flist = []
	for i in alist:
		if i < 0:
			nlist.append(i)
		else:
			plist.append(i)
	pos = len(plist)
	neg = len(nlist)
	if pos >= 5:
		res = plist[-5:]
		flist.append(res[0] * res[1] * res[2] * res[3] * res[4])
	if pos >= 4 and neg >= 1:
		res = plist[:4]
		flist.append(nlist[neg - 1] * res[0] * res[1] * res[2] * res[3])
	if pos >= 3 and neg >= 2:
		res = plist[-3:]
		nes = nlist[:2]
		flist.append(nes[0] * nes[1] * res[0] * res[1] * res[2])
	if pos >= 2 and neg >= 3:
		res = plist[:2]
		nes = nlist[-3:]
		flist.append(nes[0] * nes[1] * nes[2] * res[0] * res[1])
	if pos >= 1 and neg >= 4:
		res = plist[-1:]
		nes = nlist[:4]
		flist.append(nes[0] * nes[1] * nes[2] * res[0] * nes[3])
	if neg >= 5:
		nes = nlist[-5:]
		flist.append(nes[0] * nes[1] * nes[2] * nes[4] * nes[3])
	print(max(flist))
t = int(input())
for it in range(t):
	n = int(input())
	x = input()
	alist = [int(i) for i in x.split()]
	maxmul(alist)


for cases in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	p1 = l[-1] * l[0] * l[1] * l[2] * l[3]
	p2 = l[-1] * l[-2] * l[-3] * l[0] * l[1]
	p3 = l[-1] * l[-2] * l[-3] * l[-4] * l[-5]
	print(max(p1, p2, p3))


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
for _ in range(n):
	m = inp()
	l = inlt()
	l.sort()
	negative_counts = 0
	res = -5 * 10 ** 20
	cnt = 0
	left = 0
	right = len(l) - 1
	for j in range(5):
		tmp = 1
		for x in range(j):
			tmp *= l[x]
		for y in range(5 - j):
			tmp *= l[-y - 1]
		if tmp > res:
			res = tmp
	print(res)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = float('-inf')
	for i in range(5):
		e = (n - 1 + i) % n
		d = (n - 2 + i) % n
		c = (n - 3 + i) % n
		b = (n - 4 + i) % n
		a = (n - 5 + i) % n
		ans = max(arr[a] * arr[b] * arr[c] * arr[d] * arr[e], ans)
	print(ans)
	t -= 1


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	M = 5
	dp0 = list2d(N + 1, M + 1, -INF)
	dp1 = list2d(N + 1, M + 1, INF)
	dp0[0][0] = dp1[0][0] = 1
	for i in range(N):
		for j in range(M + 1):
			if dp0[i][j] != -INF:
				dp0[i + 1][j] = max(dp0[i + 1][j], dp0[i][j])
				if j < M:
					dp0[i + 1][j + 1] = max(dp0[i + 1][j + 1], dp0[i][j] * A[i])
					dp1[i + 1][j + 1] = min(dp1[i + 1][j + 1], dp0[i][j] * A[i])
			if dp1[i][j] != INF:
				dp1[i + 1][j] = min(dp1[i + 1][j], dp1[i][j])
				if j < M:
					dp1[i + 1][j + 1] = min(dp1[i + 1][j + 1], dp1[i][j] * A[i])
					dp0[i + 1][j + 1] = max(dp0[i + 1][j + 1], dp1[i][j] * A[i])
	ans = dp0[N][M]
	print(ans)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	A1 = []
	has0 = False
	for i in range(N):
		if A[i] > 0:
			A1.append((A[i], 1))
		elif A[i] < 0:
			A1.append((abs(A[i]), 0))
		else:
			A1.append((0, 2))
			has0 = True
	A1.sort()
	B = []
	cnt = 0
	lasti0 = lasti1 = -1
	for i in range(5):
		(a, t) = A1.pop()
		if t == 1:
			lasti1 = i
			B.append(a)
		elif t == 0:
			cnt += 1
			lasti0 = i
			B.append(a)
	B2 = B[:]
	cnt2 = cnt
	A2 = A1[:]
	while A1 and cnt % 2 == 1:
		(a, t) = A1.pop()
		if t == 1 and lasti0 != -1:
			B.pop(lasti0)
			B.append(a)
			cnt -= 1
	while A2 and cnt2 % 2 == 1:
		(a, t) = A2.pop()
		if t == 0 and lasti1 != -1:
			B2.pop(lasti1)
			B2.append(a)
			cnt2 -= 1
	ans1 = ans2 = 1
	for b in B:
		ans1 *= b
	if cnt % 2 == 1:
		ans1 = -ans1
	if len(B) < 5:
		ans1 = 0
	for b in B2:
		ans2 *= b
	if cnt2 % 2 == 1:
		ans2 = -ans2
	if len(B2) < 5:
		ans2 = 0
	ans = max(ans1, ans2)
	if ans < 0 and has0:
		ans = 0
	if ans < 0:
		ans = 1
		A.sort(reverse=1)
		for i in range(5):
			ans *= A[i]
	print(ans)


test = int(input())
for i in range(0, test):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	a.sort()
	a50 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	a32 = a[-1] * a[-2] * a[-3] * a[0] * a[1]
	a14 = a[-1] * a[0] * a[1] * a[2] * a[3]
	print(max(a50, max(a32, a14)))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		a.sort()
		if a[-1] < 0:
			r = 1
			for c in a[-5:]:
				r *= c
		else:
			t = 1
			for c in a[-5:]:
				t *= c
			u = 1
			for c in a[:2] + a[-3:]:
				u *= c
			v = a[-1]
			for c in a[:4]:
				v *= c
			r = max(t, u, v)
		rr.append(r)
	return JA(rr, '\n')
print(main())


t = int(input())
for _ in range(t):
	y = int(input())
	a = list(map(int, input().split()))
	positive = []
	negative = []
	for elem in a:
		if elem < 0:
			negative.append(elem)
		else:
			positive.append(elem)
	positive.sort(reverse=True)
	negative.sort()
	p = len(positive)
	n = len(negative)
	max_p = -10 ** 20
	if p >= 3 and n >= 2:
		pr = positive[0] * positive[1] * positive[2]
		pr *= negative[0] * negative[1]
		max_p = max(max_p, pr)
	if p >= 1 and n >= 4:
		pr = positive[0] * negative[0] * negative[1] * negative[2] * negative[3]
		max_p = max(max_p, pr)
	if p >= 5:
		pr = positive[0] * positive[1] * positive[2] * positive[3] * positive[4]
		max_p = max(max_p, pr)
	if 0 in negative:
		max_p = max(max_p, 0)
	pr = 1
	for i in range(5):
		if len(positive) * len(negative) != 0:
			if positive[-1] <= -negative[-1]:
				pr *= positive[-1]
				del positive[-1]
			else:
				pr *= negative[-1]
				del negative[-1]
		elif len(positive) != 0:
			pr *= positive[-1]
			del positive[-1]
		else:
			pr *= negative[-1]
			del negative[-1]
	max_p = max(max_p, pr)
	print(max_p)


t = int(input())
k = 5
for q in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dp = [[0 for i in range(k)] for j in range(n)]
	dp1 = [[0 for i in range(k)] for j in range(n)]
	dp[0][0] = a[0]
	dp1[0][0] = a[0]
	for i in range(1, n):
		dp[i][0] = max(dp[i - 1][0], a[i])
		dp1[i][0] = min(dp1[i - 1][0], a[i])
		for j in range(1, min(k, i + 1)):
			if i == j:
				dp[i][j] = dp[i - 1][j - 1] * a[i]
				dp1[i][j] = dp[i][j]
			else:
				dp[i][j] = dp[i - 1][j]
				dp1[i][j] = dp1[i - 1][j]
			dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] * a[i], dp1[i - 1][j - 1] * a[i])
			dp1[i][j] = min(dp1[i][j], dp[i - 1][j - 1] * a[i], dp1[i - 1][j - 1] * a[i])
	print(dp[n - 1][k - 1])


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	if n == 5:
		p = 1
		for i in ar:
			p *= i
		print(p)
	else:
		neg = []
		pos = []
		for i in ar:
			if i < 0:
				neg.append(abs(i))
			else:
				pos.append(i)
		neg.sort(reverse=True)
		pos.sort(reverse=True)
		p1 = 1
		p2 = 1
		p3 = 1
		ans = []
		if len(pos) == 0:
			nnn = neg[::-1]
			aaa = 1
			for i in range(5):
				aaa *= nnn[i]
			print(aaa * -1)
		else:
			try:
				for i in range(4):
					p1 *= neg[i]
				for i in range(1):
					p1 *= pos[i]
				ans.append(p1)
			except:
				no = 1
			try:
				for i in range(2):
					p2 *= neg[i]
				for i in range(3):
					p2 *= pos[i]
				ans.append(p2)
			except:
				no = 1
			try:
				for i in range(5):
					p3 *= pos[i]
				ans.append(p3)
			except:
				no = 1
			print(max(ans))


T = int(input().rstrip())

def get_max(posl, negl, npos, nneg):
	if len(posl) < npos or len(negl) < nneg:
		return None
	ans = 1
	if npos > 0:
		for i in posl[-npos:]:
			ans *= i
	if nneg > 0:
		for i in negl[-nneg:]:
			ans *= i
	return ans

def solve(arr):
	posl = []
	negl = []
	has_zero = False
	for i in arr:
		if i > 0:
			posl.append(i)
		elif i < 0:
			negl.append(i)
		else:
			has_zero = True
	posl.sort()
	negl.sort(reverse=True)
	all_max = [get_max(posl, negl, 5, 0), get_max(posl, negl, 3, 2), get_max(posl, negl, 1, 4)]
	best_ans = all_max[0]
	for i in range(1, len(all_max)):
		curr = all_max[i]
		if curr is not None:
			if best_ans is None:
				best_ans = curr
			elif curr > best_ans:
				best_ans = curr
	if best_ans is not None:
		if best_ans > 0:
			return best_ans
	elif has_zero:
		return 0
	negl.reverse()
	all_min = [get_max(posl, negl, 4, 1), get_max(posl, negl, 2, 3), get_max(posl, negl, 0, 5)]
	best_ans = all_min[0]
	for i in range(1, len(all_min)):
		curr = all_min[i]
		if curr is not None:
			if best_ans is None:
				best_ans = curr
			elif curr < best_ans:
				best_ans = curr
	return best_ans
for test in range(T):
	n = int(input().rstrip())
	arr = [int(x) for x in input().rstrip().split()]
	ret = solve(arr)
	print(ret)


for __ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	print(max(a[0] * a[1] * a[2] * a[3] * a[n - 1], a[0] * a[1] * a[n - 3] * a[n - 2] * a[n - 1], a[n - 5] * a[n - 4] * a[n - 3] * a[n - 2] * a[n - 1]))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	neg = 0
	for i in range(4):
		if a[i] < 0:
			neg += 1
		else:
			break
	ans = a[n - 5] * a[n - 4] * a[n - 3] * a[n - 2] * a[n - 1]
	if neg == 4:
		try1 = a[0] * a[1] * a[2] * a[3] * a[n - 1]
		if try1 > ans:
			ans = try1
		try2 = a[0] * a[1] * a[n - 3] * a[n - 2] * a[n - 1]
		if try2 > ans:
			ans = try2
	elif neg >= 2:
		test = a[0] * a[1] * a[n - 3] * a[n - 2] * a[n - 1]
		if test > ans:
			ans = test
	print(ans)


t = int(input())
for _ in range(1, t + 1):
	l = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	res = max(ar[l - 1] * ar[l - 2] * ar[l - 3] * ar[l - 4] * ar[l - 5], ar[l - 1] * ar[l - 2] * ar[l - 3] * ar[0] * ar[1], ar[l - 1] * ar[2] * ar[3] * ar[0] * ar[1])
	print(res)


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	ans = int('-1' + '0' * 1000)
	if 0 in x:
		ans = 0
	(m, p) = ([], [])
	if n < 11:
		a = x
	else:
		x.sort()
		a = x[:5] + x[-5:]
	for i1 in range(len(a)):
		for i2 in range(i1 + 1, len(a)):
			for i3 in range(i2 + 1, len(a)):
				for i4 in range(i3 + 1, len(a)):
					for i5 in range(i4 + 1, len(a)):
						if a[i1] * a[i2] * a[i3] * a[i4] * a[i5] > ans:
							ans = a[i1] * a[i2] * a[i3] * a[i4] * a[i5]
	print(ans)


import sys
import math
input = sys.stdin.readline
cases = int(input())
for case in range(cases):
	n = int(input())
	a = [int(x) for x in input().split()]
	mxp = []
	mxm = []
	a.sort()
	cnt = 0
	flag = False
	allbad = True
	for i in range(len(a)):
		if a[i] != 0:
			cnt += 1
		else:
			flag = True
		if a[i] > 0:
			allbad = False
	if cnt < 5:
		print(0)
		continue
	if not allbad:
		for i in range(5):
			if a[i] < 0:
				mxm.append(a[i])
	else:
		for i in range(len(a) - 1, len(a) - 6, -1):
			mxm.append(a[i])
	for i in range(len(a) - 1, len(a) - 6, -1):
		if a[i] > 0:
			mxm.append(a[i])
	tog = []
	for i in range(len(mxm)):
		tog.append(mxm[i])
	for i in range(len(mxp)):
		tog.append(mxp[i])
	ans = -10 ** 18
	for i in range(len(tog) - 4):
		for j in range(i + 1, len(tog) - 3):
			for k in range(j + 1, len(tog) - 2):
				for l in range(k + 1, len(tog) - 1):
					for m in range(l + 1, len(tog)):
						ans = max(ans, tog[i] * tog[j] * tog[k] * tog[l] * tog[m])
	if flag and ans < 0:
		ans = 0
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	ans = 0
	new = a[:]
	n1 = min(new)
	new.remove(n1)
	n2 = min(new)
	new.remove(n2)
	n3 = min(new)
	new.remove(n3)
	n4 = min(new)
	new.remove(n4)
	n5 = min(new)
	new.remove(n5)
	new = a[:]
	x1 = max(new)
	new.remove(x1)
	x2 = max(new)
	new.remove(x2)
	x3 = max(new)
	new.remove(x3)
	x4 = max(new)
	new.remove(x4)
	x5 = max(new)
	new.remove(x5)
	ans = max(x1 * x2 * x3 * x4 * x5, n1 * n2 * n3 * n4 * x1, n1 * n2 * x1 * x2 * x3, n1 * n2 * n3 * n4 * n5)
	print(ans)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	n = ini()
	a = sorted(inl())
	ans = 1
	if n == 5:
		for i in range(5):
			ans *= a[i]
	else:
		tmp = []
		count = 2
		for i in range(0, n, 2):
			if count == 0 or a[i] >= 0 or a[i + 1] >= 0:
				break
			tmp.append(a[i] * a[i + 1])
			count -= 1
		tmp2 = a[-1] * a[-2] * a[-3]
		ans = -(3 * 10 ** 3) ** 5 - 1
		if len(tmp) >= 2:
			ans = max(ans, tmp[0] * tmp[1] * a[-1])
		if len(tmp) >= 1:
			ans = max(ans, tmp[0] * tmp2)
		ans = max(ans, tmp2 * a[-4] * a[-5])
	print(ans)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	a = []
	b = []
	zero = False
	for i in mints():
		if i < 0:
			a.append(i)
		elif i > 0:
			b.append(i)
		else:
			zero = True
	a.sort()
	b.sort(reverse=True)
	r = None
	for i in range(6):
		if len(a) >= i and len(b) >= 5 - i:
			x = 1
			if i % 2 == 1:
				for j in range(-1, -i - 1, -1):
					x *= a[j]
				for j in range(-1, -(5 - i) - 1, -1):
					x *= b[j]
			else:
				for j in range(i):
					x *= a[j]
				for j in range(5 - i):
					x *= b[j]
			if r == None or x > r:
				r = x
	if zero:
		if r == None or 0 > r:
			r = 0
	print(r)
for i in range(mint()):
	solve()


import sys
t = int(input())
for i in range(t):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	negative = []
	positive = []
	for x in arr:
		if x >= 0:
			positive.append(x)
		else:
			negative.append(x)
	positive.sort(reverse=True)
	negative.sort()
	poslen = len(positive)
	neglen = len(negative)
	maxNum = float('-inf')
	if n == 5:
		maxNum = max(maxNum, arr[0] * arr[1] * arr[2] * arr[3] * arr[4])
	if poslen == 0:
		maxNum = max(maxNum, negative[-1] * negative[-2] * negative[-3] * negative[-4] * negative[-5])
	if poslen >= 1 and neglen >= 4:
		maxNum = max(maxNum, positive[0] * negative[0] * negative[1] * negative[2] * negative[3])
	if poslen >= 3 and neglen >= 2:
		maxNum = max(maxNum, positive[0] * positive[1] * positive[2] * negative[0] * negative[1])
	if poslen >= 5:
		maxNum = max(maxNum, positive[0] * positive[1] * positive[2] * positive[3] * positive[4])
	print(maxNum)


mod = int(1000000000.0) + 7

def prod(p, n):
	if not n:
		return 1
	t = len(p)
	ans = 1
	for i in range(0, n):
		ans *= p[i]
	return ans

def np(n):
	if n == 1:
		return int(input())
	else:
		return map(int, input().split())
for _ in range(0, int(input())):
	n = np(1)
	l = list(np(2))
	(p, ne) = ([], [])
	for i in l:
		if i >= 0:
			p.append(i)
		else:
			ne.append(i)
	ans = -1 * int(1e+18)
	p.sort(reverse=True)
	ne.sort()
	t = len(p)
	if len(p) >= 5:
		ans = prod(p, 5)
	x = len(ne)
	if not x:
		print(ans)
	elif not t:
		print(prod(ne[::-1], 5))
	else:
		(t1, t2) = (1, None)
		for i in range(0, min(x, 5)):
			t1 *= ne[i]
			if t >= 4 - i:
				ans = max(t1 * prod(p, 4 - i), ans)
		print(ans)


def ques2(n, a):
	a.sort()
	c1 = a[0] * a[1] * a[2] * a[3] * a[4]
	c2 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	c3 = a[0] * a[-1] * a[-2] * a[-3] * a[-4]
	c4 = a[0] * a[1] * a[2] * a[3] * a[-1]
	c5 = a[0] * a[1] * a[2] * a[-1] * a[-2]
	c6 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	return max(c1, c2, c3, c4, c5, c6)
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = ques2(n, a)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	A = [int(x) for x in input().split()]
	resres = -1000000000000000000000000000
	pos = [a for a in A if a >= 0]
	neg = [a for a in A if a < 0]
	pos.sort()
	neg.sort()
	if pos:
		res = pos.pop()
		pos.reverse()
		pairs = [pos[i] * pos[i + 1] for i in range(0, len(pos) - 1, 2)]
		pairs += [neg[i] * neg[i + 1] for i in range(0, len(neg) - 1, 2)]
		pairs.sort()
		if len(pairs) >= 2:
			res *= pairs[-1] * pairs[-2]
			resres = max(resres, res)
	pos = [a for a in A if a >= 0]
	neg = [a for a in A if a < 0]
	pos.sort()
	neg.sort()
	if neg:
		res = neg.pop()
		neg.reverse()
		pairs = [pos[i] * pos[i + 1] for i in range(0, len(pos) - 1, 2)]
		pairs += [neg[i] * neg[i + 1] for i in range(0, len(neg) - 1, 2)]
		pairs.sort(reverse=True)
		if len(pairs) >= 2:
			res *= pairs[-1] * pairs[-2]
			resres = max(resres, res)
	print(resres)


t = int(input())
while t > 0:
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	print(max(l[-1] * l[-2] * l[-3] * l[-4] * l[-5], l[0] * l[1] * l[-1] * l[-2] * l[-3], l[0] * l[1] * l[2] * l[3] * l[-1]))
	t = t - 1


import operator

def run():
	n = int(input())
	nums = list(map(int, input().split()))
	nums.sort()
	t1 = nums[0] * nums[1] * nums[2] * nums[3] * nums[4]
	t2 = nums[0] * nums[1] * nums[2] * nums[3] * nums[-1]
	t3 = nums[0] * nums[1] * nums[2] * nums[-2] * nums[-1]
	t4 = nums[0] * nums[1] * nums[-3] * nums[-2] * nums[-1]
	t5 = nums[0] * nums[-1] * nums[-2] * nums[-3] * nums[-4]
	t6 = nums[-5] * nums[-1] * nums[-2] * nums[-3] * nums[-4]
	print(max([t1, t2, t3, t4, t5, t6]))
for i in range(int(input())):
	run()


def highest_product_of_5(list_of_ints):
	lowest = highest = list_of_ints[0]
	lowest_product_of_2 = highest_product_of_2 = highest * list_of_ints[1]
	lowest_product_of_3 = highest_product_of_3 = lowest_product_of_2 * list_of_ints[2]
	lowest_product_of_4 = highest_product_of_4 = highest_product_of_3 * list_of_ints[3]
	highest_product_of_5 = highest_product_of_4 * list_of_ints[4]
	for (i, current) in enumerate(list_of_ints[1:]):
		if i + 1 >= 5:
			highest_product_of_5 = max(highest_product_of_5, current * highest_product_of_4, current * lowest_product_of_4)
		if i + 1 >= 4:
			highest_product_of_4 = max(highest_product_of_4, current * highest_product_of_3, current * lowest_product_of_3)
			lowest_product_of_4 = min(lowest_product_of_4, current * highest_product_of_3, current * lowest_product_of_3)
		if i + 1 >= 3:
			highest_product_of_3 = max(highest_product_of_3, current * highest_product_of_2, current * lowest_product_of_2)
			lowest_product_of_3 = min(lowest_product_of_3, current * highest_product_of_2, current * lowest_product_of_2)
		if i + 1 >= 2:
			highest_product_of_2 = max(highest_product_of_2, current * highest, current * lowest)
			lowest_product_of_2 = min(lowest_product_of_2, current * highest, current * lowest)
		highest = max(highest, current)
		lowest = min(lowest, current)
	return highest_product_of_5
t = int(input())
for req in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(highest_product_of_5(a))


import math
t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	(pos, neg, zero) = (0, 0, 0)
	for i in range(n):
		pos += a[i] > 0
		neg += a[i] < 0
		zero += a[i] == 0
	if pos == 0 or neg == 0:
		print(a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
	else:
		ans = a[-1]
		ans *= max(a[0] * a[1] * a[2] * a[3], a[0] * a[1] * a[-2] * a[-3], a[-2] * a[-3] * a[-4] * a[-5])
		print(ans)
	t -= 1


import sys as _sys

def main():
	t = int(input())
	for i in range(t):
		(n,) = _read_ints()
		a = tuple(_read_ints())
		result = find_max_possible_n_elements_product(a, product_members_n=5)
		print(result)

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split(' '))

def find_max_possible_n_elements_product(sequence, product_members_n):
	sequence = sorted(sequence)
	assert len(sequence) >= product_members_n
	best_products = []
	for lowest_n in range(0, product_members_n + 1):
		highest_n = product_members_n - lowest_n
		best_lowest = sequence[:lowest_n]
		best_highest = sequence[len(sequence) - highest_n:]
		product = 1
		for x in best_lowest + best_highest:
			product *= x
		best_products.append(product)
	return max(best_products)
main()


import sys, threading

def inpt():
	return sys.stdin.readline().rstrip()

def read():
	return [int(x) for x in inpt().split()]
from functools import reduce

def mul(a):
	if a == []:
		return 1
	return reduce(lambda x, y: x * y, a)

def main():
	(_T_,) = read()
	for _t_ in range(_T_):
		(n,) = read()
		ar = read()
		pos = []
		neg = []
		for i in ar:
			if i < 0:
				neg.append(i)
			else:
				pos.append(i)
		neg.sort()
		pos.sort()
		ans = -float('inf')
		for k in range(6):
			p = k
			ne = 5 - k
			if len(pos) >= p and len(neg) >= ne:
				if ne % 2 == 0:
					ans = max(ans, mul(pos[-p:]) * mul(neg[:ne]))
				else:
					ans = max(ans, mul(pos[-p:]) * mul(neg[-ne:]))
		print(ans)
if 1:
	sys.setrecursionlimit(10 ** 7)
	threading.stack_size(10 ** 8)
	threading.Thread(target=main).start()
else:
	main()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	lis1 = []
	lis2 = []
	a = 0
	b = 0
	c = arr.count(0)
	for i in range(n):
		if arr[i] > 0:
			lis1.append(arr[i])
			a += 1
		elif arr[i] < 0:
			lis2.append(arr[i])
			b += 1
	lis1.sort()
	lis2.sort(reverse=True)
	if a + b < 5:
		print(0)
	elif a >= 5:
		if b >= 4:
			x = lis2[-1] * lis2[-2] * lis2[-3] * lis2[-4] * lis1[-1]
			y = lis2[-1] * lis2[-2] * lis1[-1] * lis1[-2] * lis1[-3]
			z = lis1[-5] * lis1[-4] * lis1[-1] * lis1[-2] * lis1[-3]
			print(max(x, y, z))
		elif b >= 2:
			y = lis2[-1] * lis2[-2] * lis1[-1] * lis1[-2] * lis1[-3]
			z = lis1[-5] * lis1[-4] * lis1[-1] * lis1[-2] * lis1[-3]
			print(max(y, z))
		else:
			print(lis1[-5] * lis1[-4] * lis1[-1] * lis1[-2] * lis1[-3])
	elif a == 4:
		if b >= 4:
			x = lis2[-1] * lis2[-2] * lis2[-3] * lis2[-4] * lis1[-1]
			y = lis2[-1] * lis2[-2] * lis1[-1] * lis1[-2] * lis1[-3]
			print(max(x, y))
		elif b >= 2:
			y = lis2[-1] * lis2[-2] * lis1[-1] * lis1[-2] * lis1[-3]
			print(y)
		elif c > 0:
			print(0)
		else:
			z = lis2[-1] * lis1[-4] * lis1[-1] * lis1[-2] * lis1[-3]
			print(z)
	elif a == 3:
		if b >= 4:
			x = lis2[-1] * lis2[-2] * lis2[-3] * lis2[-4] * lis1[-1]
			y = lis2[-1] * lis2[-2] * lis1[-1] * lis1[-2] * lis1[-3]
			print(max(x, y))
		elif b >= 2:
			y = lis2[-1] * lis2[-2] * lis1[-1] * lis1[-2] * lis1[-3]
			print(y)
	elif a == 2:
		if b >= 4:
			x = lis2[-1] * lis2[-2] * lis2[-3] * lis2[-4] * lis1[-1]
			print(x)
		elif b == 3:
			if c > 0:
				print(0)
			else:
				z = lis2[-1] * lis2[-2] * lis2[-3] * lis1[-2] * lis1[-1]
				print(z)
	elif a == 1:
		if b >= 4:
			x = lis2[-1] * lis2[-2] * lis2[-3] * lis2[-4] * lis1[-1]
			print(x)
	elif c > 0:
		print(0)
	else:
		print(lis2[0] * lis2[1] * lis2[2] * lis2[3] * lis2[4])


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	zer = 0
	pos = []
	neg = []
	for i in lis:
		if i == 0:
			zer += 1
		elif i > 0:
			pos.append(i)
		else:
			neg.append(i)
	if len(pos) + len(neg) < 5:
		print(0)
	else:
		pos.sort(reverse=True)
		neg.sort(reverse=True)
		ans = -1000000000000000000000000
		tmp = 1
		if len(pos) >= 5:
			for i in range(5):
				tmp *= pos[i]
			ans = tmp
		if len(pos) >= 4 and len(neg) >= 1:
			tmp = 1
			for i in range(4):
				tmp *= pos[i]
			tmp *= neg[0]
			ans = max(ans, tmp)
		if len(pos) >= 3 and len(neg) >= 2:
			tmp = 1
			for i in range(3):
				tmp *= pos[i]
			tmp *= neg[-1] * neg[-2]
			ans = max(ans, tmp)
		if len(pos) >= 2 and len(neg) >= 3:
			tmp = 1
			tmp = pos[0] * pos[1] * neg[0] * neg[1] * neg[2]
			ans = max(ans, tmp)
		if len(pos) >= 1 and len(neg) >= 4:
			tmp = pos[0] * neg[-4] * neg[-1] * neg[-2] * neg[-3]
			ans = max(ans, tmp)
		if len(neg) >= 5:
			tmp = neg[0] * neg[1] * neg[2] * neg[3] * neg[4]
			ans = max(ans, tmp)
		if zer:
			ans = max(ans, 0)
		print(ans)


def mi():
	return map(int, input().split())
import sys, os
try:
	for _ in range(int(input())):
		noise = int(input())
		a = list(mi())
		a.sort()
		(p, n) = ([], [])
		for i in a:
			if i < 0:
				n.append(i)
			else:
				p.append(i)
		if len(p) == 0:
			ans = n[-1] * n[-2] * n[-3] * n[-4] * n[-5]
			print(ans)
			continue
		ans = p[-1]
		added = 1
		p.remove(p[-1])
		if len(p) >= 2 and len(n) >= 2:
			if p[-1] * p[-2] > n[0] * n[1]:
				ans *= p[-1] * p[-2]
				added += 2
				p.remove(p[-1])
				p.remove(p[-1])
			else:
				ans *= n[0] * n[1]
				added += 2
				n.remove(n[0])
				n.remove(n[0])
		elif len(p) >= 4:
			added += 4
			ans *= p[-1] * p[-2] * p[-3] * p[-4]
		elif len(n) >= 4:
			added += 4
			ans *= n[0] * n[1] * n[2] * n[3]
		if added == 3:
			if len(p) >= 2 and len(n) >= 2:
				if p[-1] * p[-2] > n[0] * n[1]:
					ans *= p[-1] * p[-2]
					added += 2
				else:
					ans *= n[0] * n[1]
					added += 2
			elif len(p) >= 2:
				ans *= p[-1] * p[-2]
			elif len(n) >= 2:
				ans *= n[0] * n[1]
		if added == 1:
			ans = 1
			for i in range(5):
				ans *= a[i]
		print(ans)
except IndexError as e:
	for i in range(1010101010101010101):
		print('lol, how did the index error creep in')


import math
import sys
import collections
import bisect
import time

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	n = int(input())
	arr = get_list()
	arr.sort()
	if max(arr) == 0:
		print(0)
		continue
	if max(arr) < 0:
		ans = 1
		d = 0
		for i in range(n - 1, -1, -1):
			ans *= arr[i]
			d += 1
			if d == 5:
				break
		print(ans)
		continue
	case1 = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	case2 = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	case3 = arr[-1] * arr[-2] * arr[-3] * arr[0] * arr[1]
	print(max(case1, case2, case3))


def prod(arr):
	ans = 1
	for a in arr:
		ans *= a
	return ans
t = int(input())
buf = []
for _ in range(t):
	n = int(input())
	aaa = list(map(int, input().split()))
	if n == 5:
		buf.append(prod(aaa))
		continue
	minus = []
	zeros_cnt = 0
	plus = []
	for a in aaa:
		if a < 0:
			minus.append(a)
		elif a == 0:
			zeros_cnt += 1
		else:
			plus.append(a)
	minus.sort()
	plus.sort()
	if len(plus) == 0:
		if zeros_cnt > 0:
			buf.append(0)
		else:
			buf.append(prod(minus[-5:]))
	else:
		ans = 0
		if len(plus) >= 5:
			ans = max(ans, prod(plus[-5:]))
		if len(minus) >= 2 and len(plus) >= 3:
			ans = max(ans, prod(minus[:2]) * prod(plus[-3:]))
		if len(minus) >= 4 and len(plus) >= 1:
			ans = max(ans, prod(minus[:4]) * prod(plus[-1:]))
		buf.append(ans)
print('\n'.join(map(str, buf)))


for i in range(int(input())):
	n = int(input())
	number = sorted(map(int, input().split(' ')))
	p_1 = number[0] * number[1] * number[n - 1] * number[n - 2] * number[n - 3]
	p_2 = number[0] * number[1] * number[2] * number[3] * number[n - 1]
	p_3 = number[n - 1] * number[n - 2] * number[n - 3] * number[n - 4] * number[n - 5]
	print(max(p_1, p_2, p_3))


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	ans = max(a[-1] * a[-2] * a[-3] * a[1] * a[0], a[0] * a[1] * a[2] * a[3] * a[-1], a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
	print(ans)


T = int(input())
while T > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	res = float('-inf')
	res = max(res, arr[-5] * arr[-4] * arr[-3] * arr[-2] * arr[-1])
	res = max(res, arr[-4] * arr[-3] * arr[-2] * arr[-1] * arr[0])
	res = max(res, arr[-3] * arr[-2] * arr[-1] * arr[0] * arr[1])
	res = max(res, arr[-2] * arr[-1] * arr[0] * arr[1] * arr[2])
	res = max(res, arr[-1] * arr[0] * arr[1] * arr[2] * arr[3])
	res = max(res, arr[0] * arr[1] * arr[2] * arr[3] * arr[4])
	print(res)
	T -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	zero = 0
	num = -(243 * 10 ** 15 + 10)
	for i in range(n):
		if arr[i] == 0:
			zero += 1
			break
	arr.sort()
	ans = num
	for i in range(min(6, n)):
		prod = 1
		for j in range(i):
			prod *= arr[j]
		for j in range(5 - i):
			prod *= arr[n - j - 1]
		ans = max(ans, prod)
	if ans < 0 and zero:
		print(0)
	else:
		print(ans)


I = lambda : map(int, input().split())
for _ in [0] * int(input()):
	n = int(input())
	a = list(I())
	a.sort()
	x = 1
	if a[0] >= 0 or a[-1] <= 0:
		for i in range(n - 5, n, 1):
			x = a[i] * x
	else:
		c = [0] * 3
		c[0] = a[0] * a[1] * a[-1] * a[-2] * a[-3]
		c[1] = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
		c[2] = a[0] * a[1] * a[-1] * a[2] * a[3]
		x = max(c)
	print(x)


def maxVal(arr):
	arr.sort()
	positives = 0
	negatives = 0
	zero = False
	for i in range(len(arr)):
		if arr[i] < 0:
			negatives += 1
		elif arr[i] > 0:
			positives += 1
		else:
			zero = True
	if negatives < 2 or arr[-1] < 0:
		total = 1
		for i in range(len(arr) - 1, len(arr) - 6, -1):
			total *= arr[i]
		return total
	else:
		l = 0
		r = len(arr) - 2
		total = arr[-1]
		if total == 0:
			return 0
		for i in range(2):
			if arr[l] * arr[l + 1] > arr[r] * arr[r - 1]:
				total *= arr[l] * arr[l + 1]
				l += 2
			else:
				total *= arr[r] * arr[r - 1]
				r -= 2
		return total
T = int(input())
for t in range(T):
	N = int(input())
	arr = [int(i) for i in input().split(' ')]
	print(maxVal(arr))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ar_min = arr[:5]
	small = min(ar_min)
	ar_max = arr[:5]
	large = max(ar_max)
	for i in range(5, len(arr)):
		if arr[i] < large:
			ar_min.remove(large)
			ar_min.append(arr[i])
			large = max(ar_min)
		if arr[i] > small:
			ar_max.remove(small)
			ar_max.append(arr[i])
			small = min(ar_max)
	ar_max.sort()
	ar_min.sort()
	p1 = 1
	p2 = ar_max[-1]
	p3 = ar_max[4] * ar_max[3] * ar_max[2] * ar_min[0] * ar_min[1]
	for i in ar_max:
		p1 *= i
	for i in ar_min[:4]:
		p2 *= i
	ans = max([p1, p2, p3])
	print(ans)


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	a.sort()
	ans = -9e+18
	for i in range(6):
		cur = 1
		for j in range(i):
			cur *= a[j]
		for j in range(n - 5 + i, n):
			cur *= a[j]
		ans = max(ans, cur)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a, key=abs, reverse=True)
	j = 0
	q = 1
	f = 0
	for j in range(n):
		if a[j] >= 0:
			f = 1
			break
	if f == 1:
		for j in range(5):
			q = q * a[j]
	else:
		for j in range(n - 1, n - 6, -1):
			q = q * a[j]
	if q > 0 or n == 5:
		print(q)
	elif f == 0:
		print(q)
	else:
		k = 0
		j = 0
		v = 1
		m = 0
		while j < n:
			if a[j] < 0 and k < 2:
				k = k + 1
				v = v * a[j]
			elif a[j] >= 0 and m < 3:
				v = v * a[j]
				m = m + 1
			j = j + 1
		if k == 2 and m == 3:
			q = max(q, v)
		k = 0
		j = 0
		v = 1
		m = 0
		while j < n and m < 5:
			if a[j] >= 0:
				v = v * a[j]
				m = m + 1
			j = j + 1
		if m == 5:
			q = max(q, v)
		k = 0
		j = 0
		v = 1
		m = 0
		while j < n:
			if a[j] < 0 and k < 4:
				k = k + 1
				v = v * a[j]
			elif a[j] >= 0 and m < 1:
				v = v * a[j]
				m = m + 1
			j = j + 1
		if k == 4 and m == 1:
			q = max(q, v)
		print(q)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	alst = list(map(int, input().split()))
	alst.sort()
	minus = []
	plus = []
	zero = False
	for a in alst:
		if a < 0:
			minus.append(a)
		elif a > 0:
			plus.append(a)
		if a == 0:
			zero = True
	if len(minus) + len(plus) < 5:
		print(0)
		return
	plus = plus[::-1]
	ans = -10 ** 20
	if zero:
		ans = 0
	if len(plus) == 0:
		if zero:
			print(0)
			return
		minus.sort(reverse=True)
		ans = 1
		for a in minus[:5]:
			ans *= a
		print(ans)
		return
	for i in range(6):
		tmp = 1
		try:
			for j in range(i):
				tmp *= plus[j]
			for j in range(5 - i):
				tmp *= minus[j]
			ans = max(ans, tmp)
		except IndexError:
			pass
	print(ans)
for _ in range(int(input())):
	main()


for adfsda in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mot = []
	mpo = []
	cz = False
	for i in range(n):
		if a[i] < 0:
			mot.append(a[i])
		elif a[i] > 0:
			mpo.append(a[i])
		else:
			cz = True
	if cz:
		maxa = 0
	else:
		maxa = a[0] * a[1] * a[2] * a[3] * a[4]
	mot.sort()
	mpo.sort(reverse=True)
	for i in range(0, 6, 2):
		if len(mot) < i:
			continue
		elif len(mpo) < 5 - i:
			continue
		cm = 1
		for j in range(i):
			cm *= mot[j]
		for j in range(5 - i):
			cm *= mpo[j]
		maxa = max(maxa, cm)
	for i in range(1, 6, 2):
		if len(mot) < i:
			continue
		elif len(mpo) < 5 - i:
			continue
		cm = 1
		for j in range(i):
			cm *= mot[-j - 1]
		for j in range(5 - i):
			cm *= mpo[-j - 1]
		maxa = max(maxa, cm)
	print(maxa)


from sys import *
from math import *
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	neg = []
	pos = []
	for i in range(n):
		if a[i] < 0:
			neg.append(a[i])
		else:
			pos.append(a[i])
	l1 = len(neg)
	l2 = len(pos)
	neg.sort()
	pos.sort()
	pos = pos[::-1]
	ans = []
	if l1 >= 5 and l2 >= 0:
		ans.append(neg[l1 - 2] * neg[l1 - 5] * neg[l1 - 3] * neg[l1 - 4] * neg[l1 - 1])
	if l1 >= 4 and l2 >= 1:
		ans.append(neg[0] * neg[1] * neg[2] * neg[3] * pos[0])
	if l1 >= 3 and l2 >= 2:
		ans.append(neg[l1 - 2] * neg[l1 - 3] * neg[l1 - 1] * pos[l2 - 1] * pos[l2 - 2])
	if l1 >= 2 and l2 >= 3:
		ans.append(neg[0] * neg[1] * pos[0] * pos[1] * pos[2])
	if l1 >= 1 and l2 >= 4:
		ans.append(neg[l1 - 1] * pos[l2 - 1] * pos[l2 - 2] * pos[l2 - 3] * pos[l2 - 4])
	if l1 >= 0 and l2 >= 5:
		ans.append(pos[4] * pos[3] * pos[0] * pos[1] * pos[2])
	print(max(ans))


import math
from decimal import *
import random
for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	print(max(arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5], arr[0] * arr[1] * arr[n - 1] * arr[n - 2] * arr[n - 3], arr[0] * arr[1] * arr[2] * arr[3] * arr[n - 1]))


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	a = [i for i in a if i]
	ans = -10 ** 100
	if len(a) < n:
		ans = 0
	n = len(a)
	if len(a) < 5:
		print(0)
		continue
	a.sort()
	c = sum((i > 0 for i in a))
	ans = max(ans, a[-1] * a[-2] * a[-3] * a[-4] * a[-5], a[0] * a[1] * a[-1] * a[-2] * a[-3], a[0] * a[1] * a[2] * a[3] * a[-1])
	print(ans)


from sys import stdin, stdout
from collections import defaultdict as dd
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = max(a[0] * a[1] * a[2] * a[3] * a[-1], a[0] * a[1] * a[-2] * a[-3] * a[-1], a[-5] * a[-4] * a[-2] * a[-3] * a[-1])
	print(ans)


from collections import Counter

def func(A):
	(p, n) = ([], [])
	for i in A:
		if i >= 0:
			p.append(i)
		else:
			n.append(i)
	p.sort()
	n.sort()
	if len(A) == 5:
		return A[-1] * A[-2] * A[-3] * A[-4] * A[-5]
	if not p:
		return n[-1] * n[-2] * n[-3] * n[-4] * n[-5]
	if not n:
		return p[-1] * p[-2] * p[-3] * p[-4] * p[-5]
	(f, s, t) = (float('-inf'), float('-inf'), float('-inf'))
	if len(p) >= 5:
		f = p[-1] * p[-2] * p[-3] * p[-4] * p[-5]
	if len(p) >= 3 and len(n) >= 2:
		s = p[-1] * p[-2] * p[-3] * n[0] * n[1]
	if len(p) >= 1 and len(n) >= 4:
		t = p[-1] * n[0] * n[1] * n[2] * n[3]
	return max(s, f, t)
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	print(func(A))


import sys

def insertion(x, A):
	i = 0
	while i < len(A) and A[i] < x:
		i = i + 1
	if i == len(A):
		A.append(x)
	else:
		A.append(0)
		for j in range(len(A) - i - 1):
			A[len(A) - j - 1] = A[len(A) - j - 2]
		A[i] = x

def F(A):
	Max = []
	Min = []
	for i in range(5):
		insertion(A[i], Max)
		insertion(A[i], Min)
	for i in range(5, len(A)):
		if A[i] > Max[0]:
			del Max[0]
			insertion(A[i], Max)
		if A[i] < Min[4]:
			del Min[4]
			insertion(A[i], Min)
	res1 = Max[4] * Max[3] * Max[2] * Max[1] * Max[0]
	res2 = Max[4] * Max[3] * Max[2] * Min[0] * Min[1]
	res3 = Max[4] * Min[0] * Min[1] * Min[2] * Min[3]
	res = max(res1, res2, res3)
	print(res)
for j in range(int(input())):
	_ = input()
	A = list(map(int, input().split()))
	F(A)


for ad in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	pos = []
	neg = []
	for i in l:
		if i >= 0:
			pos.append(i)
		else:
			neg.append(i)
	c = 1
	if len(pos) == 0:
		neg.sort()
		neg.reverse()
		ans = 1
		for i in range(5):
			ans *= neg[i]
	elif len(pos) == 1 or len(pos) == 3:
		i = 0
		j = n - 2
		c *= max(l[i] * l[i + 1], l[j] * l[j - 1])
		if l[i] * l[i + 1] >= l[j] * l[j - 1]:
			i += 2
		else:
			j -= 2
		c *= max(l[i] * l[i + 1], l[j] * l[j - 1])
		if l[i] * l[i + 1] >= l[j] * l[j - 1]:
			i += 2
		else:
			j -= 2
		d = c * l[-1]
		ans = d
	elif len(pos) == 2 or len(pos) == 4:
		i = 0
		j = n - 2
		c *= max(l[i] * l[i + 1], l[j] * l[j - 1])
		if l[i] * l[i + 1] >= l[j] * l[j - 1]:
			i += 2
		else:
			j -= 2
		c *= max(l[i] * l[i + 1], l[j] * l[j - 1])
		if l[i] * l[i + 1] >= l[j] * l[j - 1]:
			i += 2
		else:
			j -= 2
		d = c * l[-1]
		ans = d
	else:
		i = 0
		j = n - 2
		c *= max(l[i] * l[i + 1], l[j] * l[j - 1])
		if l[i] * l[i + 1] >= l[j] * l[j - 1]:
			i += 2
		else:
			j -= 2
		c *= max(l[i] * l[i + 1], l[j] * l[j - 1])
		if l[i] * l[i + 1] >= l[j] * l[j - 1]:
			i += 2
		else:
			j -= 2
		d = c * l[-1]
		ans = d
	print(ans)


t = int(input())
res = []
for i in range(t):
	s = int(input())
	arr = sorted([int(x) for x in input().split()])
	n1 = arr[len(arr) - 5] * arr[len(arr) - 4] * arr[len(arr) - 3] * arr[len(arr) - 2] * arr[len(arr) - 1]
	n2 = arr[len(arr) - 4] * arr[len(arr) - 3] * arr[len(arr) - 2] * arr[len(arr) - 1] * arr[0]
	n3 = arr[len(arr) - 3] * arr[len(arr) - 2] * arr[len(arr) - 1] * arr[0] * arr[1]
	n4 = arr[len(arr) - 2] * arr[len(arr) - 1] * arr[0] * arr[1] * arr[2]
	n5 = arr[len(arr) - 1] * arr[0] * arr[1] * arr[2] * arr[3]
	res.append(max(n1, n2, n3, n4, n5))
for e in res:
	print(e)


for _ in range(int(input())):
	n = int(input())
	l = [*map(int, input().split())]
	dp = [[float('inf'), -float('inf')] for _ in range(n + 1)]
	for i in range(1, n + 1):
		dp[i] = [min(dp[i - 1][0], dp[i][0], l[i - 1]), max(dp[i - 1][1], dp[i][1], l[i - 1])]
	for i in range(2, 6):
		new_dp = [[float('inf'), -float('inf')] for _ in range(n + 1)]
		for j in range(i, n + 1):
			new_dp[j] = [min(new_dp[j - 1][0], dp[j - 1][l[j - 1] < 0] * l[j - 1]), max(new_dp[j - 1][1], dp[j - 1][l[j - 1] > 0] * l[j - 1])]
		dp = new_dp
	print(max(dp[-1]))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	ans = a[-1]
	a = a[:-1]
	if ans > 0:
		if a[0] * a[1] > a[-1] * a[-2]:
			ans *= a[0] * a[1]
			a = a[2:]
		else:
			ans *= a[-1] * a[-2]
			a = a[:-2]
		ans *= max(a[0] * a[1], a[-1] * a[-2])
	else:
		if a[0] * a[1] < a[-1] * a[-2]:
			ans *= a[0] * a[1]
			a = a[2:]
		else:
			ans *= a[-1] * a[-2]
			a = a[:-2]
		ans *= min(a[0] * a[1], a[-1] * a[-2])
	print(ans)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	la = n
	if n > 9:
		a = a[:5] + a[-5:]
		la = 10
	mv = (-3 * 10 ** 3) ** 5
	for i in range(la - 4):
		for j in range(i + 1, la - 3):
			for k in range(j + 1, la - 2):
				for l in range(k + 1, la - 1):
					for m in range(l + 1, la):
						mv = max(a[i] * a[j] * a[k] * a[l] * a[m], mv)
	print(mv)


def prod(a):
	product = 1
	for x in a:
		product *= x
	return product
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	zeros = a.count(0)
	if n - zeros < 5:
		print(0)
	elif n == 5:
		s = 1
		for x in a:
			s *= x
		print(s)
	else:
		a.sort()
		shot1 = prod(a[-5:])
		shot2 = prod(a[-3:] + a[:2])
		shot3 = prod(a[-1:] + a[:4])
		print(max(shot3, shot2, shot1))


def maxProduct(arr, n):
	arr.sort()
	a = arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3]
	b = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	c = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	if a > b:
		maxi = a
	else:
		maxi = b
	if c > maxi:
		maxi = c
	return maxi
t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 5:
		max = 1
		for e in arr:
			max = max * e
	else:
		max = maxProduct(arr, n)
	print(max)
	t -= 1


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import deque
for j in range(int(input())):
	n = int(input())
	vals = list(map(int, input().split()))
	pos = []
	neg = []
	for s in range(n):
		if vals[s] >= 0:
			pos.append(vals[s])
		else:
			neg.append(vals[s])
	pos.sort()
	neg.sort(reverse=True)
	ans = 0
	found = False
	if len(pos) >= 5:
		ans = max(ans, pos[-1] * pos[-2] * pos[-3] * pos[-4] * pos[-5])
		found = True
	if len(pos) >= 3 and len(neg) >= 2:
		ans = max(ans, pos[-1] * pos[-2] * pos[-3] * neg[-1] * neg[-2])
		found = True
	if len(pos) >= 1 and len(neg) >= 4:
		ans = max(ans, pos[-1] * neg[-1] * neg[-2] * neg[-3] * neg[-4])
		found = True
	if found == False:
		a1 = 1
		tick = 0
		pos = deque(pos)
		neg = deque(neg)
		while tick < 5:
			if len(pos) > 0 and len(neg) > 0:
				if abs(pos[0]) <= abs(neg[0]):
					a1 *= pos.popleft()
				else:
					a1 *= neg.popleft()
			elif len(pos) > 0:
				a1 *= pos.popleft()
			else:
				a1 *= neg.popleft()
			tick += 1
		ans = a1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().rstrip().split()))
	l.sort()
	ans = max(l[0] * l[1] * l[-1] * l[-2] * l[-3], l[0] * l[1] * l[2] * l[3] * l[-1], l[-1] * l[-2] * l[-3] * l[-4] * l[-5])
	print(ans)


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = inar()
		neg = []
		pos = []
		for i in range(n):
			if arr[i] < 0:
				neg.append(arr[i])
			else:
				pos.append(arr[i])
		neg.sort()
		pos.sort(reverse=True)
		ans = -1 * 10 ** 18
		if len(neg) >= 5:
			temp = neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5]
			ans = max(ans, temp)
		if len(neg) >= 4 and len(pos) >= 1:
			temp = neg[0] * neg[1] * neg[2] * neg[3] * pos[0]
			ans = max(ans, temp)
		if len(neg) >= 3 and len(pos) >= 2:
			temp = neg[-1] * neg[-2] * neg[-3] * pos[-1] * pos[-2]
			ans = max(ans, temp)
		if len(neg) >= 2 and len(pos) >= 3:
			temp = neg[0] * neg[1] * pos[0] * pos[1] * pos[2]
			ans = max(ans, temp)
		if len(neg) >= 1 and len(pos) >= 4:
			temp = neg[-1] * pos[-1] * pos[-2] * pos[-3] * pos[-4]
			ans = max(ans, temp)
		if len(pos) >= 5:
			temp = pos[0] * pos[1] * pos[2] * pos[3] * pos[4]
			ans = max(ans, temp)
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pos = []
	neg = []
	for j in a:
		if j >= 0:
			pos.append(j)
		else:
			neg.append(j)
	pos.sort(reverse=True)
	neg.sort()
	ans = 1
	if len(pos) == 0:
		for j in range(1, 6):
			ans *= neg[-j]
	elif len(pos) <= 2:
		if len(neg) >= 4:
			for j in range(4):
				ans *= neg[j]
			ans *= pos[0]
		else:
			for j in range(3):
				ans *= neg[j]
			ans *= pos[0] * pos[1]
	elif len(pos) <= 4:
		ans = 0
		cur = 1
		if len(neg) >= 4:
			for j in range(4):
				cur *= neg[j]
			cur *= pos[0]
			ans = cur
		if len(neg) >= 2:
			ans = max(ans, pos[0] * pos[1] * pos[2] * neg[0] * neg[1])
		if len(neg) == 1:
			ans = 1
			for j in range(4):
				ans *= pos[j]
			ans *= neg[0]
	else:
		ans = 0
		if len(neg) >= 4:
			cur = 1
			for j in range(4):
				cur *= neg[j]
			cur *= pos[0]
			ans = cur
		if len(neg) >= 2:
			ans = max(ans, pos[0] * pos[1] * pos[2] * neg[0] * neg[1])
		cur = 1
		for j in range(5):
			cur *= pos[j]
		ans = max(ans, cur)
	print(ans)


t = int(input())
for i in range(0, t):
	m = int(input())
	arr = list(map(int, input().strip().split()))[:m]
	arr.sort(reverse=True)
	mul1 = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	mul2 = arr[0] * arr[-1] * arr[-2] * arr[-3] * arr[-4]
	mul3 = arr[0] * arr[1] * arr[2] * arr[-1] * arr[-2]
	mul = max(mul1, mul2, mul3)
	print(mul)


def max_product(arrs):
	for arr in arrs:
		if all([i < 0 for i in arr]):
			arr.sort(reverse=True)
			prod = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
			print(prod)
			continue
		arr.sort(key=abs, reverse=True)
		prod = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
		if prod >= 0:
			print(int(prod))
		else:
			maxprod = prodtemp = prod
			for i in arr[5:]:
				for j in range(4, -1, -1):
					prodtemp = 1
					for k in range(5):
						if k != j:
							prodtemp *= arr[k]
					prodtemp *= i
					maxprod = max(maxprod, prodtemp)
			print(int(maxprod))
t = int(input())
arrs = []
for _ in range(t):
	_ = input()
	arr = [int(i) for i in input().split()]
	arrs.append(arr)
max_product(arrs)


n = int(input().strip())
for i in range(n):
	input()
	num = sorted([int(i) for i in input().strip().split()])
	(a, b, c, d, e, f, g, h, i) = (num[-5], num[-4], num[-3], num[-2], num[-1], num[0], num[1], num[2], num[3])
	print(max(a * b * c * d * e, f * g * c * d * e, f * g * h * i * e))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 5:
		ans = 1
		for i in a:
			ans *= i
		print(ans)
		continue
	a.sort()
	val1 = a[0] * a[1] * a[2] * a[3] * a[-1]
	val2 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	val3 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	val4 = a[0] * a[1] * a[2] * a[3] * a[4]
	print(max(val1, val2, val3, val4))


for i in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	a = sorted(list1)
	neg = []
	pos = []
	for i in range(n):
		if a[i] < 0:
			neg.append(a[i])
		else:
			pos.append(a[i])
	neg_ans = a[-1] * a[-2] * a[-3] * a[0] * a[1]
	neg_ans1 = a[-1] * a[3] * a[2] * a[1] * a[0]
	if n > 5:
		pos_value = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	else:
		pos_value = a[-1] * a[-2] * a[-3] * a[-4] * a[0]
	d = max(pos_value, neg_ans1, neg_ans)
	print(d)


from collections import defaultdict, Counter
import copy, math
from copy import deepcopy
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	s = -9999999999999999999999999999999
	s = max(s, l[-1] * l[-2] * l[-3] * l[-4] * l[-5])
	s = max(s, l[0] * l[1] * l[2] * l[3] * l[4])
	s = max(s, l[0] * l[1] * l[-1] * l[-2] * l[-3])
	s = max(s, l[1] * l[-1] * l[2] * l[3] * l[0])
	print(s)


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	x = l[-1] * l[-2] * l[-3] * l[-4] * l[-5]
	y = l[-1] * l[-2] * l[-3] * l[0] * l[1]
	z = l[-1] * l[0] * l[1] * l[2] * l[3]
	print(max(x, y, z))


from math import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from collections import Counter as ctr
from collections import deque as dq
from array import array
from re import search
li = lambda : list(map(int, input().split()))
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')
yn = lambda f: print('NYOE S'[f::2])
sbstr = lambda a, s: search('.*'.join(a), s)

def solve():
	for _ in range(int(input())):
		n = int(input())
		a = li()
		a.sort()
		print(max((prod(a[:i] + a[i - 5:]) for i in [0, 2, 4])))
solve()


import sys
input = sys.stdin.buffer.readline

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		k = 5
		A = list(map(int, input().split()))
		PZ = []
		N = []
		for a in A:
			if a >= 0:
				PZ.append(a)
			else:
				N.append(a)
		flag = True
		if len(PZ) > 0:
			if n == k:
				if len(N) % 2 != 0:
					flag = False
		elif k % 2 != 0:
			flag = False
		if flag:
			if k % 2 == 0:
				PZ.sort(reverse=True)
				N.sort()
				s = len(PZ)
				t = len(N)
				C = []
				for i in range(s // 2):
					C.append(PZ[2 * i] * PZ[2 * i + 1])
				for i in range(t // 2):
					C.append(N[2 * i] * N[2 * i + 1])
				C.sort(reverse=True)
				ans = 1
				for i in range(k // 2):
					ans *= C[i]
			else:
				PZ.sort()
				ans = PZ.pop()
				PZ.reverse()
				N.sort()
				s = len(PZ)
				t = len(N)
				C = []
				for i in range(s // 2):
					C.append(PZ[2 * i] * PZ[2 * i + 1])
				for i in range(t // 2):
					C.append(N[2 * i] * N[2 * i + 1])
				C.sort(reverse=True)
				for i in range(k // 2):
					ans *= C[i]
		else:
			ABS = [abs(a) for a in A]
			ABS.sort()
			ans = 1
			for i in range(k):
				ans *= ABS[i]
			ans *= -1
		print(ans)
main()


def ans(n, arr):
	if n == 5:
		return arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	import sys
	lt = []
	met = []
	arr.sort(reverse=True, key=lambda x: (abs(x), x))
	for i in arr:
		if i >= 0:
			met.append(i)
		else:
			lt.append(i)
	m = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	if len(met) == 0:
		m = max(m, lt[-1] * lt[-2] * lt[-3] * lt[-4] * lt[-5])
	if len(met) >= 5:
		m = max(m, met[0] * met[1] * met[2] * met[3] * met[4])
	if len(met) >= 3 and len(lt) >= 2:
		m = max(m, met[0] * met[1] * met[2] * lt[0] * lt[1])
	if len(met) >= 1 and len(lt) >= 4:
		m = max(m, lt[0] * lt[1] * lt[2] * lt[3] * met[0])
	return m
t = int(input())
L = []
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	L.append(ans(n, arr))
for l in L:
	print(l)


def prod(a):
	product = 1
	for x in a:
		product *= x
	return product
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	shot1 = prod(a[-5:])
	shot2 = prod(a[-3:] + a[:2])
	shot3 = prod(a[-1:] + a[:4])
	print(max(shot3, shot2, shot1))


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	n = len(l)
	i = 0
	a = []
	c = l[0] * l[1] * l[2] * l[3] * l[4]
	a.append(c)
	c = l[0] * l[1] * l[2] * l[3] * l[n - 1]
	a.append(c)
	c = l[0] * l[1] * l[2] * l[n - 2] * l[n - 1]
	a.append(c)
	c = l[0] * l[1] * l[n - 3] * l[n - 2] * l[n - 1]
	a.append(c)
	c = l[0] * l[n - 4] * l[n - 3] * l[n - 2] * l[n - 1]
	a.append(c)
	c = l[n - 5] * l[n - 4] * l[n - 3] * l[n - 2] * l[n - 1]
	a.append(c)
	a.sort()
	ans = a[len(a) - 1]
	print(ans)


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	a.sort(reverse=True)
	ans1 = a[0] * a[1] * a[2] * a[n - 1] * a[n - 2]
	ans2 = a[0] * a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4]
	ans3 = a[0] * a[1] * a[2] * a[3] * a[4]
	print(max(ans1, ans2, ans3))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	brr = []
	brr.append(arr[0] * arr[1] * arr[n - 3] * arr[n - 2] * arr[n - 1])
	brr.append(arr[0] * arr[1] * arr[2] * arr[3] * arr[n - 1])
	brr.append(arr[n - 5] * arr[n - 4] * arr[n - 3] * arr[n - 2] * arr[n - 1])
	print(max(brr))


from __future__ import division, print_function
INF = 10 ** 10
TEST_CASES = True
from collections import defaultdict, deque, Counter
from functools import reduce

def main():
	n = get_int()
	li = get_list()
	li.sort()
	ans = -10 ** 20 if 0 not in li else 0
	for i in range(6):
		ans = max(ans, reduce(lambda x, y: x * y, li[:i] + li[-(5 - i):] if i < 5 else li[:i]))
	print(ans)
import os
import sys
from bisect import bisect_left, bisect_right, bisect
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
if TEST_CASES:
	[main() for _ in range(int(input()))]
else:
	main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	z = list(map(int, input().strip().split()))[:n]
	ans = 1
	z.sort()
	ans = z[n - 1] * z[n - 2] * z[n - 3] * z[n - 4] * z[n - 5]
	ans = max(ans, z[n - 1] * z[0] * z[1] * z[2] * z[3])
	ans = max(ans, z[n - 1] * z[n - 2] * z[n - 3] * z[0] * z[1])
	print(ans)


import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
	n = int(sys.stdin.readline().strip())
	a = list(map(int, sys.stdin.readline().strip().split()))
	a.sort()
	print(max([a[0] * a[1] * a[2] * a[3] * a[-1], a[0] * a[1] * a[-3] * a[-2] * a[-1], a[-5] * a[-4] * a[-3] * a[-2] * a[-1]]))


def cal(a, s):
	if a[0] < 0:
		k = a[0] * -1
		if k > a[-1]:
			s = s * a[0]
			a.remove(a[0])
		else:
			s = s * a[-1]
			a.remove(a[-1])
	elif a[0] >= 0:
		s = s * a[0]
		a.remove(a[0])
	return s
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	(s, k) = (1, 0)
	(s1, s2, s3, s4) = (0, 0, 0, 0)
	if len(a) == 5:
		for i in range(len(a)):
			s = s * a[i]
		print(s)
	else:
		for i in range(5):
			if a[i] < 0:
				k += 1
		l = len(a)
		if k == 2 or k == 3:
			s1 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
			s2 = a[-4] * a[-5] * a[-1] * a[-2] * a[-3]
		elif k == 4 or k > 4:
			s1 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
			s2 = a[0] * a[1] * a[-1] * a[3] * a[2]
			s3 = a[0] * a[1] * a[2] * a[-1] * a[3]
			s4 = a[-4] * a[-5] * a[-1] * a[-2] * a[-3]
		if k == 4 or k > 4:
			for i in range(4):
				s = cal(a, s)
			if s < 0:
				s = s * a[0]
			elif s > 0:
				s = s * a[-1]
			else:
				s = s * a[-1]
		elif k == 2 or k == 3:
			for i in range(2):
				s = cal(a, s)
			if s < 0:
				s = s * a[0]
				a.remove(a[0])
			elif s > 0:
				s = s * a[-1]
				a.remove(a[-1])
			else:
				s = s * a[-1]
				a.remove(a[-1])
			s = s * a[-1] * a[-2]
		else:
			for i in range(5):
				s = s * a[-1]
				a.remove(a[-1])
		print(max(s, s1, s2, s3, s4))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mx = a[0] * a[1] * a[2] * a[3] * a[n - 1]
	mx = max(mx, a[0] * a[1] * a[n - 3] * a[n - 2] * a[n - 1])
	mx = max(mx, a[n - 5] * a[n - 4] * a[n - 3] * a[n - 2] * a[n - 1])
	print(mx)


import sys
from decimal import Decimal
from collections import defaultdict as dc
import math
from bisect import bisect_left, bisect_right
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if l[-1] == 0:
		print(0)
	elif l[-1] < 0:
		x = 1
		c = 0
		for i in range(n - 1, -1, -1):
			if c >= 5:
				break
			else:
				x *= l[i]
				c += 1
		print(x)
	else:
		i = 0
		j = n - 1
		x = 1
		x *= l[j]
		j -= 1
		c = 0
		while c < 2 and i <= j:
			a = l[i] * l[i + 1]
			b = l[j] * l[j - 1]
			if a > b:
				x *= a
				i += 2
			else:
				x *= b
				j -= 2
			c += 1
		print(x)


import math
t = int(input())
for _ in range(t):
	N = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	x1 = lst[-1] * lst[-2] * lst[-3] * lst[-4] * lst[-5]
	x2 = lst[0] * lst[1] * lst[-1] * lst[-2] * lst[-3]
	x3 = lst[0] * lst[1] * lst[2] * lst[3] * lst[-1]
	print(max(x1, x2, x3))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	lst = list(map(int, input().split()))
	pos = []
	neg = []
	for i in range(n):
		if lst[i] < 0:
			neg.append(lst[i])
		else:
			pos.append(lst[i])
	ans = -11000000000000000000000000000007
	neg.sort()
	pos.sort()
	if len(neg) >= 5:
		ans = max(ans, neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5])
	if len(pos) >= 4 and len(neg) >= 1:
		ans = max(ans, neg[-1] * pos[0] * pos[1] * pos[2] * pos[3])
	if len(neg) >= 2 and len(pos) >= 3:
		ans = max(ans, neg[0] * neg[1] * pos[-1] * pos[-2] * pos[-3])
	if len(neg) >= 3 and len(pos) >= 2:
		ans = max(ans, neg[-1] * neg[-2] * neg[-3] * pos[0] * pos[1])
	if len(neg) >= 4 and len(pos) >= 1:
		ans = max(ans, neg[0] * neg[1] * neg[2] * neg[3] * pos[-1])
	if len(pos) >= 5:
		ans = max(ans, pos[-1] * pos[-2] * pos[-3] * pos[-4] * pos[-5])
	if ans < 0 and len(pos) > 0 and (pos[0] == 0):
		ans = 0
	print(ans)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	c1 = arr[-5] * arr[-4] * arr[-3] * arr[-2] * arr[-1]
	c2 = arr[0] * arr[1] * arr[-3] * arr[-2] * arr[-1]
	c3 = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	print(max(c1, c2, c3))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = []
	s = a[0] * a[1] * a[2] * a[3] * a[-1]
	t = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	u = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	print(max(s, t, u))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l, reverse=True)
	a = l[0] * l[1] * l[2] * l[3] * l[4]
	b = l[0] * l[1] * l[2] * l[-1] * l[-2]
	c = l[0] * l[-1] * l[-2] * l[-3] * l[-4]
	print(max(a, b, c))


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = [int(x) for x in input().split()]
	arrp = []
	arrn = []
	for i in range(0, len(s)):
		if s[i] < 0:
			arrn.append(abs(s[i]))
		else:
			arrp.append(abs(s[i]))
	arrp.sort()
	arrn.sort()
	inf = (-3000) ** 5
	N = 2 ** 5
	dp = [inf] * N
	for i in range(N):
		tt = bin(i)
		tt = tt[2:]
		tt = '0' * (5 - len(tt)) + tt
		c0 = tt.count('0')
		c1 = tt.count('1')
		if c0 % 2 != 0:
			mul = 1
			if len(arrn) < c0 or len(arrp) < c1:
				dp[i] = inf
			else:
				for j in range(c0):
					mul *= arrn[j]
				for j in range(c1):
					mul *= arrp[j]
				dp[i] = -mul
		else:
			mul = 1
			if len(arrn) < c0 or len(arrp) < c1:
				dp[i] = inf
			else:
				for j in range(len(arrn) - 1, len(arrn) - c0 - 1, -1):
					mul *= arrn[j]
				for j in range(len(arrp) - 1, len(arrp) - c1 - 1, -1):
					mul *= arrp[j]
				dp[i] = mul
	ans = inf
	for i in range(N):
		ans = max(ans, dp[i])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	a = ar[n - 1] * ar[n - 2] * ar[n - 3] * ar[n - 4] * ar[n - 5]
	b = ar[n - 1] * ar[n - 2] * ar[n - 3] * ar[0] * ar[1]
	c = ar[n - 1] * ar[0] * ar[1] * ar[2] * ar[3]
	mn = max(a, b, c)
	print(mn)


t = input()
t = int(t)
for i in range(t):
	n = input()
	n = int(n)
	a = []
	b = []
	arr = list(map(int, input().rstrip().split()))
	arr.sort()
	d = arr[0] * arr[1] * arr[2] * arr[3] * arr[n - 1]
	e = arr[0] * arr[1] * arr[n - 1] * arr[n - 2] * arr[n - 3]
	f = arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5]
	arr1 = [d, e, f]
	print(max(arr1))


from math import inf

def solve():
	z = []
	p = []
	n = []
	for v in a:
		if v > 0:
			p.append(v)
		elif v < 0:
			n.append(v)
		else:
			z.append(v)
	p.sort()
	n.sort()
	if not p and (not n):
		print(0)
	elif not n:
		if len(p) >= 5:
			print(p[-1] * p[-2] * p[-3] * p[-4] * p[-5])
		else:
			print(0)
	elif not p:
		if z:
			print(0)
		else:
			print(n[-1] * n[-2] * n[-3] * n[-4] * n[-5])
	elif not p and (not z):
		print(n[-1] * n[-2] * n[-3] * n[-4] * n[-5])
	else:
		ans = -inf
		try:
			tmp = p[-1] * p[-2] * p[-3] * p[-4] * p[-5]
			ans = max(ans, tmp)
		except:
			pass
		try:
			tmp = n[0] * p[-1] * p[-2] * p[-3] * p[-4]
			ans = max(ans, tmp)
		except:
			pass
		try:
			tmp = n[0] * n[1] * p[-1] * p[-2] * p[-3]
			ans = max(ans, tmp)
		except:
			pass
		try:
			tmp = n[0] * n[1] * n[2] * p[-1] * p[-2]
			ans = max(ans, tmp)
		except:
			pass
		try:
			tmp = n[0] * n[1] * n[2] * n[3] * p[-1]
			ans = max(ans, tmp)
		except:
			pass
		try:
			tmp = n[0] * n[1] * n[2] * n[3] * n[4]
			ans = max(ans, tmp)
		except:
			pass
		if ans < 0 and z:
			ans = 0
		print(ans)
for _ in range(int(input())):
	num = int(input())
	a = list(map(int, input().split()))
	solve()


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	print(max(lis[0] * lis[1] * lis[-3] * lis[-2] * lis[-1], lis[0] * lis[1] * lis[2] * lis[3] * lis[-1], lis[1] * lis[2] * lis[3] * lis[4] * lis[0], lis[-1] * lis[-2] * lis[-3] * lis[-4] * lis[-5]))


def prod(A, B):
	prod = 1
	for i in A:
		prod *= i
	for j in B:
		prod *= j
	return prod

def answer(n, A):
	A.sort()
	maxi = -10 ** 20
	for i in range(6):
		p = prod(A[:i], A[n - 5 + i:])
		maxi = max(maxi, p)
	return maxi
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	print(answer(n, l))


t = int(input())
while t > 0:
	n = int(input())
	x = [int(i) for i in input().split()]
	x.sort()
	c1 = x[n - 5] * x[n - 4] * x[n - 3] * x[n - 2] * x[n - 1]
	c2 = x[n - 4] * x[n - 3] * x[n - 2] * x[n - 1] * x[0]
	c3 = x[n - 3] * x[n - 2] * x[n - 1] * x[0] * x[1]
	c4 = x[n - 2] * x[n - 1] * x[0] * x[1] * x[2]
	c5 = x[n - 1] * x[0] * x[1] * x[2] * x[3]
	c6 = x[0] * x[1] * x[2] * x[3] * x[4]
	print(max(c1, c2, c3, c4, c5, c6))
	t -= 1


for _ in range(int(input())):
	num = int(input())
	array = sorted(list(map(int, input().split())))
	first_two = array[0] * array[1] * array[-1] * array[-2] * array[-3]
	first_four = array[0] * array[1] * array[2] * array[3] * array[-1]
	last_two = array[-1] * array[-2] * array[0] * array[1] * array[2]
	last_four = array[-1] * array[-2] * array[-3] * array[-4] * array[0]
	first_five = array[0] * array[1] * array[2] * array[3] * array[4]
	last_five = array[-1] * array[-2] * array[-3] * array[-4] * array[-5]
	ans = max(first_two, first_four, last_two, last_four, first_five, last_five)
	print(ans)


t = int(input())
results = []
for i in range(t):
	n = int(input())
	vals = input().split()
	a = [int(val) for val in vals]
	if n == 5:
		results.append(a[0] * a[1] * a[2] * a[3] * a[4])
	else:
		a.sort()
		prod_max = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
		for j in range(1, 5):
			prod = a[-1 + j] * a[-2 + j] * a[-3 + j] * a[-4 + j] * a[-5 + j]
			if prod > prod_max:
				prod_max = prod
		results.append(prod_max)
for result in results:
	print(result)


from collections import defaultdict

def fun(l):
	a = 1
	for i in l:
		a *= i
	return a
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = -10000000000000000000000000
	for i in range(5):
		p1 = fun(l[:i]) * fun(l[(5 - i) * -1:])
		ans = max(ans, p1)
	print(ans)


def get1():
	a = A[::-1]
	b = B[:]
	if len(a):
		ans = a.pop(0)
	else:
		ans = b.pop(0)
	for _ in range(2):
		if len(a) > 1 and len(b) > 1:
			if a[0] * a[1] > b[0] * b[1]:
				ans *= a.pop(0) * a.pop(0)
			else:
				ans *= b.pop(0) * b.pop(0)
		elif len(a) > 1:
			ans *= a.pop(0) * a.pop(0)
		elif len(b) > 1:
			ans *= b.pop(0) * b.pop(0)
		else:
			ans *= a.pop(0) * b.pop(0)
	return ans

def get2():
	a = A[:]
	b = B[::-1]
	ans = 1
	for i in range(5):
		if len(a) and len(b):
			if a[0] < abs(b[0]):
				ans *= a.pop(0)
			else:
				ans *= b.pop(0)
		elif len(a):
			ans *= a.pop(0)
		else:
			ans *= b.pop(0)
	return ans
for _ in range(int(input())):
	n = int(input())
	(A, B) = ([], [])
	for i in map(int, input().split()):
		if i >= 0:
			A.append(i)
		else:
			B.append(i)
	A.sort()
	B.sort()
	print(max(get1(), get2()))


for s in [*open(0)][2::2]:
	a = sorted(map(int, s.split()))
	r = -1 << 58
	for i in range(5):
		p = 1
		for x in a[:i] + a[i - 5:]:
			p *= x
		r = max(r, p)
	print(r)


test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	c1 = 1
	for i in range(5):
		c1 *= arr[-i - 1]
	c2 = 1
	for i in range(3):
		c2 *= arr[-i - 1]
	for i in range(2):
		c2 *= arr[i]
	c3 = 1
	for i in range(4):
		c3 *= arr[i]
	c3 *= arr[-1]
	print(max(c1, c2, c3))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(k) for k in input().split(' ')]
	a.sort()
	if a[-1] <= 0:
		print(a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
	else:
		p = 0
		q = n - 2
		result = a[-1]
		if a[p] * a[p + 1] > a[q] * a[q - 1]:
			result = result * a[p] * a[p + 1]
			p = p + 2
		else:
			result = result * a[q] * a[q - 1]
			q = q - 2
		if a[p] * a[p + 1] > a[q] * a[q - 1]:
			result = result * a[p] * a[p + 1]
			p = p + 2
		else:
			result = result * a[q] * a[q - 1]
			q = q - 2
		print(result)


ko = 10 ** 18
t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	neg = []
	pos = []
	for i in li:
		if i < 0:
			neg.append(i)
		else:
			pos.append(i)
	neg.sort()
	pos.sort()
	z = min(5, len(neg))
	maxa = -ko
	yo = len(pos)
	for i in range(z + 1):
		ans = 1
		for j in range(i):
			ans = ans * neg[j]
		if yo < 5 - i:
			continue
		for k in range(5 - i):
			ans = ans * pos[-(k + 1)]
		maxa = max(maxa, ans)
	for i in range(z + 1):
		ans = 1
		for j in range(i):
			ans = ans * neg[-(j + 1)]
		if yo < 5 - i:
			continue
		for k in range(5 - i):
			ans = ans * pos[k]
		maxa = max(maxa, ans)
	print(maxa)


t = int(input())
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	a.sort()
	ans = a[0] * a[1] * a[2] * a[3] * a[4]
	for i in range(5):
		tmp = 1
		for j in range(i):
			tmp *= a[j]
		for j in range(5 - i):
			tmp *= a[-j - 1]
		ans = max(ans, tmp)
	if ans < 0 and 0 in a:
		ans = 0
	print(ans)


tst = int(input())
t = 1
while t <= tst:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = max(a[-1] * a[-2] * a[-3] * a[0] * a[1], a[0] * a[1] * a[2] * a[3] * a[-1], a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
	print(x)
	t += 1


import math
for s in [*open(0)][2::2]:
	a = sorted(map(int, s.split()))
	print(max((math.prod(a[:i] + a[i - 5:]) for i in range(5))))


from bisect import bisect_left, bisect_right
import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	na = a[:bisect_left(a, 0)]
	pa = a[bisect_right(a, 0):][::-1]
	a.sort(key=lambda x: abs(x))
	ans = a[0] * a[1] * a[2] * a[3] * a[4]
	if len(pa) >= 5:
		ans = max(ans, pa[0] * pa[1] * pa[2] * pa[3] * pa[4])
	if len(pa) >= 3 and len(na) >= 2:
		ans = max(ans, pa[0] * pa[1] * pa[2] * na[0] * na[1])
	if len(pa) >= 1 and len(na) >= 4:
		ans = max(ans, pa[0] * na[0] * na[1] * na[2] * na[3])
	print(ans)


def Ans():
	N = int(input())
	for i in range(N):
		A = int(input())
		B = sorted(list(map(int, input().split())))
		ans = []
		c = 1
		ans += [B[0] * B[1] * B[-1] * B[-2] * B[-3]]
		ans += [B[-1] * B[-2] * B[-3] * B[-4] * B[-5]]
		ans += [B[0] * B[1] * B[2] * B[3] * B[-1]]
		print(max(ans))
Ans()


import math
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if n == 5:
		print(arr[0] * arr[1] * arr[2] * arr[3] * arr[4])
	else:
		ma = -math.inf
		ma = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
		for i in range(6):
			ans = 1
			for j in range(i):
				ans = ans * arr[j]
			for j in range(n - 1, n - 6 + i, -1):
				ans = ans * arr[j]
			ma = max(ans, ma)
		print(ma)


n = int(input())
for i in range(n):
	t = int(input())
	x = [int(i) for i in input().split(' ')]
	(y, z) = ([], [])
	x.sort()
	for j in range(len(x)):
		if x[j] > 0:
			y.append(x[j])
		else:
			z.append(x[j])
	z.sort(reverse=True)
	y.sort(reverse=True)
	z = z + y
	answers = []
	for i in range(0, len(z) - 4):
		ans = 1
		for j in range(i, i + 5):
			ans *= z[j]
		answers.append(ans)
	answers.sort()
	print(answers[-1])


t = int(input())
for i in range(0, t):
	n = int(input())
	L = list(map(int, input().split()))
	L.sort()
	ncount = 0
	for i in range(0, n):
		if L[i] < 0:
			ncount += 1
	if ncount == 0 or n == 5:
		print(L[-1] * L[-2] * L[-3] * L[-4] * L[-5])
	else:
		p1 = L[0] * L[1] * L[-1] * L[-2] * L[-3]
		p2 = L[0] * L[1] * L[2] * L[3] * L[-1]
		p3 = L[-1] * L[-2] * L[-3] * L[-4] * L[-5]
		print(max(p1, p2, p3))


def maxproduct(A):
	A.sort()
	n = len(A)
	ans = 1
	if A[-1] == 0:
		return 0
	if A[-1] < 0:
		for i in range(n - 1, n - 5 - 1, -1):
			ans *= A[i]
		return ans
	i = 0
	j = n - 2
	ans *= A[-1]
	for _ in range(2):
		left = A[i] * A[i + 1]
		right = A[j] * A[j - 1]
		if left > right:
			ans *= left
			i += 2
		else:
			ans *= right
			j -= 2
	return ans
for _ in range(int(input())):
	n = int(input())
	arr = [*map(int, input().split())]
	print(maxproduct(arr))


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort(reverse=True)
	x = 1
	y = 1
	z = 1
	for i in range(5):
		x *= lis[i]
	for i in range(3):
		y *= lis[i]
	for i in range(n - 2, n):
		y *= lis[i]
	z = lis[0]
	for i in range(n - 4, n):
		z *= lis[i]
	print(max(x, y, z))


import sys
from itertools import product

def all_repeat(str1, rno):
	chars = list(str1)
	results = []
	for c in product(chars, repeat=rno):
		results.append(c)
	return results
input = sys.stdin.readline
t = int(input())
for t1 in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	neg = []
	pos = []
	zero = []
	c = all_repeat('01', 5)
	ans = -10 ** 20
	for i in range(n):
		if l[i] < 0:
			neg.append(l[i])
		else:
			pos.append(l[i])
	neg.sort()
	pos.sort()
	neg = neg[::-1]
	pn = len(neg) - 1
	pp = len(pos) - 1
	for i in range(len(c)):
		z = c[i]
		nn = pn
		np = pp
		curr = 1
		f = 0
		fl = 0
		cn = 0
		for j in range(len(z)):
			if z[j] == '0':
				cn += 1
		if cn % 2 != 0:
			fl = 1
			nn = 0
			np = 0
		for j in range(len(z)):
			if z[j] == '0':
				if fl == 1:
					if nn < len(neg):
						curr *= neg[nn]
						nn += 1
					else:
						f = 1
				elif nn > -1:
					curr *= neg[nn]
					nn -= 1
				else:
					f = 1
			elif fl == 1:
				if np < len(pos):
					curr *= pos[np]
					np += 1
				else:
					f = 1
			elif np > -1:
				curr *= pos[np]
				np -= 1
			else:
				f = 1
		if f == 0:
			ans = max(ans, curr)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	a.sort()
	ans = -1e+19
	for i in range(5):
		aa = (n - 1 + i) % n
		ab = (n - 2 + i) % n
		ac = (n - 3 + i) % n
		ad = (n - 4 + i) % n
		ae = (n - 5 + i) % n
		ans = max(ans, a[aa] * a[ab] * a[ac] * a[ad] * a[ae])
	print(ans)


from sys import stdin, stdout
import math
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	a.sort(reverse=True)
	pos = 0
	zeroes = a.count(0)
	neg = 0
	ans = []
	for i in range(n):
		if a[i] > 0:
			pos += 1
		else:
			break
	for i in range(n):
		if a[i] < 0:
			neg += 1
	ans.append(a[0] * a[1] * a[2] * a[3] * a[4])
	ans.append(a[0] * a[1] * a[2] * a[n - 1] * a[n - 2])
	ans.append(a[0] * a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4])
	ans.append(a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5])
	print(max(ans))


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()

def sss(a):
	ans = 1
	for i in a:
		ans *= i
	return ans
t = II()
for q in range(t):
	n = II()
	a = LI()
	a.sort()
	m = sss(a[-5:])
	m = max(m, sss(a[-3:] + a[:2]))
	m = max(m, sss(a[-1:] + a[:4]))
	print(m)


import math
import heapq

def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	if n == 5:
		prod = 1
		for x in arr:
			prod *= x
		print(prod)
		return
	arr.sort()
	prod = 1
	ansarr = [arr[0] * arr[1] * arr[2] * arr[3] * arr[4], arr[0] * arr[1] * arr[2] * arr[3] * arr[-1], arr[0] * arr[1] * arr[2] * arr[-2] * arr[-1], arr[0] * arr[1] * arr[-3] * arr[-2] * arr[-1], arr[0] * arr[-4] * arr[-3] * arr[-2] * arr[-1], arr[-5] * arr[-4] * arr[-3] * arr[-2] * arr[-1]]
	ans = max(ansarr)
	print(ans)
	return

def main():
	t = int(input())
	for i in range(t):
		solve()
	return
main()


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = -float('inf')
	arr.sort()
	if n == 5:
		print(arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5])
		continue
	ans = max(ans, arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5])
	ans = max(ans, arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[0])
	ans = max(ans, arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[1] * arr[0])
	ans = max(ans, arr[n - 1] * arr[n - 2] * arr[2] * arr[1] * arr[0])
	ans = max(ans, arr[n - 1] * arr[3] * arr[2] * arr[1] * arr[0])
	ans = max(ans, arr[4] * arr[3] * arr[2] * arr[1] * arr[0])
	print(ans)


def solution():
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = l[-1] * l[-2] * l[-3] * l[-4] * l[-5]
	if m < l[-1] * l[-2] * l[-3] * l[0] * l[1]:
		m = l[-1] * l[-2] * l[-3] * l[0] * l[1]
	if m < l[-1] * l[2] * l[3] * l[0] * l[1]:
		m = l[-1] * l[2] * l[3] * l[0] * l[1]
	print(m)
t = int(input())
while t > 0:
	solution()
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	(a, b, c) = (0, 0, 0)
	(p, q, k) = (1, 1, 1)
	w = arr[n - 5:n]
	r = arr[0:2] + arr[n - 3:n]
	s = arr[0:4] + arr[n - 1:n]
	while a != 5:
		p = p * w[a]
		q = q * r[a]
		k = k * s[a]
		a += 1
	print(max(p, q, k))


results = []
for i in range(int(input())):
	input()
	a = list(map(int, input().split()))
	if len(a) == 5:
		results.append(a[0] * a[1] * a[2] * a[3] * a[4])
	else:
		a = sorted(a)
		maxA = a[-5] * a[-4] * a[-3] * a[-2] * a[-1]
		for i in range(5):
			maxA = max(maxA, a[-5 + i] * a[-4 + i] * a[-3 + i] * a[-2 + i] * a[-1 + i])
		results.append(maxA)
for i in results:
	print(i)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(_) for _ in input().split()]
	a.sort()
	four_minus = []
	cnt = 0
	for i in a:
		if i < 0:
			four_minus.append(i)
			cnt += 1
		else:
			break
		if cnt == 4:
			break
	l = len(four_minus)
	(minus_one, minus_two) = (None, None)
	if l == 4:
		minus_one = four_minus[0] * four_minus[1]
		minus_two = four_minus[2] * four_minus[3]
	if l >= 2:
		minus_one = four_minus[0] * four_minus[1]
	if minus_one is not None and minus_two is not None:
		ans = minus_one * minus_two * a[-1]
		ans = max(ans, minus_one * a[-1] * a[-2] * a[-3])
		ans = max(ans, a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
	elif minus_one is not None:
		ans = minus_one * a[-1] * a[-2] * a[-3]
		ans = max(ans, a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
	else:
		ans = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	arr = l()
	(z, pos, neg) = (0, [], [])
	for i in range(n):
		if arr[i] < 0:
			neg.append(arr[i])
			continue
		if arr[i] > 0:
			pos.append(arr[i])
			continue
		z += 1
	pos.sort()
	neg.sort()
	if n - z <= 4:
		out(0)
		continue
	if not pos:
		if z:
			out(0)
			continue
		answer = 1
		for i in range(1, 6):
			answer *= neg[-i]
		out(answer)
		continue
	if not neg:
		answer = 1
		for i in range(1, 6):
			answer *= pos[-i]
		out(answer)
		continue
	if z:
		answer = 0
	else:
		answer = float('-inf')
	for i in range(6):
		if len(pos) < i:
			continue
		if len(neg) < 5 - i:
			continue
		(t1, t2) = (1, 1)
		if i & 1:
			for j in range(1, i + 1):
				t1 *= pos[-j]
			for j in range(5 - i):
				t2 *= neg[j]
		else:
			for j in range(i):
				t1 *= pos[j]
			for j in range(1, 6 - i):
				t2 *= neg[-j]
		answer = max(answer, t1 * t2)
	out(answer)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	ans = -float('inf')
	arr.sort()
	ans = max(ans, arr[0] * arr[1] * arr[2] * arr[3] * arr[4])
	ans = max(ans, arr[0] * arr[1] * arr[2] * arr[3] * arr[-1])
	ans = max(ans, arr[0] * arr[1] * arr[2] * arr[-2] * arr[-1])
	ans = max(ans, arr[0] * arr[1] * arr[-3] * arr[-2] * arr[-1])
	ans = max(ans, arr[0] * arr[-4] * arr[-3] * arr[-2] * arr[-1])
	ans = max(ans, arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5])
	out(ans)


import sys
from copy import *
from bisect import *

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	n = fi()
	a = li()
	p = []
	m = []
	for i in range(n):
		if a[i] > 0:
			p.append(a[i])
		if a[i] < 0:
			m.append(-a[i])
	if len(p) + len(m) < 5:
		print(0)
		continue
	p.sort(reverse=True)
	m.sort(reverse=True)
	ans = 0
	for i in [0, 2, 4]:
		if i > len(m):
			continue
		if 5 - i > len(p):
			continue
		c = 1
		for j in range(i):
			c *= m[j]
		for j in range(5 - i):
			c *= p[j]
		ans = max(ans, c)
	if len(p) == 0:
		m = m[::-1]
		c = -1
		for i in range(5):
			c *= m[i]
		ans = c
		if len(p) + len(m) != n:
			ans = 0
	if n == 5:
		ans = 1
		for i in a:
			ans *= i
	print(ans)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	ans = A[-1] * A[-2] * A[-3] * A[-4] * A[-5]
	ans = max(A[0] * A[1] * A[-1] * A[-2] * A[-3], ans)
	ans = max(A[0] * A[1] * A[2] * A[3] * A[-1], ans)
	print(ans)


t = int(input())
for j in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort(reverse=True)
	ans1 = li[-1] * li[-2] * li[0] * li[1] * li[2]
	ans2 = li[-1] * li[-2] * li[-3] * li[-4] * li[0]
	ans3 = li[1] * li[2] * li[3] * li[4] * li[0]
	print(max(ans1, ans2, ans3))


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	if a[-1] < 0:
		print(a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
	else:
		print(max(a[-1] * a[0] * a[1] * a[2] * a[3], a[-1] * a[-2] * a[-3] * a[0] * a[1], a[-1] * a[-2] * a[-3] * a[-4] * a[-5]))


def maxProduct(arr, n):
	if n < 5:
		return -1
	arr.sort()
	return max(arr[0] * arr[1] * arr[2] * arr[3] * arr[n - 1], arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5], arr[0] * arr[1] * arr[n - 1] * arr[n - 2] * arr[n - 3])
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	_max = maxProduct(arr, n)
	print(_max)


def res(l):
	l.sort()
	dpf = []
	c = 1
	for i in range(0, 5):
		c = c * l[i]
		dpf.append(c)
	if len(l) == 5:
		print(dpf[-1])
		return
	dpl = []
	c = 1
	for i in range(len(l) - 1, len(l) - 6, -1):
		c = c * l[i]
		dpl.append(c)
	result = dpf[-1]
	for i in range(3, -1, -1):
		result = max(result, dpf[i] * dpl[4 - i - 1])
	result = max(result, dpl[-1])
	print(result)
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	l = list(map(int, input().split(' ')))
	res(l)


from collections import deque
for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	m = -float('inf')
	for i in range(0, 5 + 1):
		(np, nn) = (i, 5 - i)
		pro = 1
		for i in range(nn):
			pro *= l[i]
		for i in range(np):
			pro *= l[len(l) - i - 1]
		m = max(m, pro)
	print(m)


import itertools
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	if a[-1] < 0:
		candidates = a[-5:]
		product = 1
		for i in candidates:
			product *= i
		print(product)
		continue
	positives = list(reversed(a[len(a) - 5:]))
	while positives and positives[-1] < 0:
		positives.pop()
	negatives = a[:5]
	while negatives and negatives[-1] >= 0:
		negatives.pop()
	candidates = positives + negatives
	assert len(candidates) >= 5
	product_values = []
	for combination in itertools.combinations(candidates, 5):
		product = 1
		for i in combination:
			product *= i
		product_values.append(product)
	print(max(product_values))


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	A.sort()
	ans1 = 1
	for i in range(N - 1, N - 6, -1):
		ans1 *= A[i]
	ans2 = 1
	for i in range(N - 1, N - 4, -1):
		ans2 *= A[i]
	for i in range(0, 2):
		ans2 *= A[i]
	ans3 = 1
	for i in range(N - 1, N - 2, -1):
		ans3 *= A[i]
	for i in range(0, 4):
		ans3 *= A[i]
	print(max(ans1, ans2, ans3))


from sys import stdin
from math import prod
input = stdin.readline
for test in range(int(input())):
	n = int(input())
	lst = sorted(list(map(int, input().strip().split())), reverse=True)
	a = prod(lst[0:1] + lst[n - 4:n])
	b = prod(lst[0:3] + lst[n - 2:n])
	c = prod(lst[0:5])
	print(max(a, b, c))


from sys import stdin, stdout, setrecursionlimit
import heapq
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007

def getans(arr):
	res = float('-inf')
	a = combinations(arr, 5)
	for i in a:
		cur = 1
		for j in i:
			cur *= j
		res = max(res, cur)
	return res
tc = ii1()
for _ in range(tc):
	n = ii1()
	arr = sorted(iia())
	if len(arr) <= 10:
		print(getans(arr))
	else:
		print(getans(arr[:5] + arr[-5:]))


import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))

def f(arr, l, r):
	p = 1
	for i in range(l, r):
		p *= arr[i % len(arr)]
	return p

def main():
	ans_ = []
	for _ in range(int(input())):
		n = int(input())
		arr = read()
		arr.sort()
		ans = -float('inf')
		for i in range(n - 5, n + 1):
			ans = max(ans, f(arr, i, i + 5))
		ans_.append(ans)
	print('\n'.join(map(str, ans_)))
main()


import math
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = -1e+18
	for i in range(5):
		ee = a[(n - 1 + i) % n]
		dd = a[(n - 2 + i) % n]
		cc = a[(n - 3 + i) % n]
		bb = a[(n - 4 + i) % n]
		aa = a[(n - 5 + i) % n]
		val = ee * dd * cc * bb * aa
		ans = max(ans, val)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	result = []
	count = 1
	if n == 5:
		for k in arr:
			count *= k
		print(count)
	else:
		arr = sorted(arr)
		a = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
		b = arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3]
		c = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
		d = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
		result.append(a)
		result.append(b)
		result.append(c)
		result.append(d)
		print(max(result))


T = int(input())
for i in range(T):
	N = int(input())
	x = list(map(int, input().split()))
	x.sort()
	ans1 = x[0] * x[1] * x[N - 1] * x[N - 2] * x[N - 3]
	ans2 = x[0] * x[1] * x[2] * x[3] * x[N - 1]
	ans3 = x[N - 5] * x[N - 4] * x[N - 1] * x[N - 2] * x[N - 3]
	final = max(ans1, max(ans2, ans3))
	print(final)


import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

def solve(t, A):
	pos = []
	negas = []
	ans = []
	for a in A:
		if a >= 0:
			pos.append(a)
		else:
			negas.append(-1 * a)
	pos = sorted(pos)
	rev_pos = pos[::-1]
	negas = sorted(negas)
	rev_negas = negas[::-1]
	for i in range(6):
		if len(pos) >= i and len(negas) >= 5 - i:
			p = 1
			if i % 2 == 0:
				for k in pos[:i]:
					p *= k
				for k in negas[:5 - i]:
					p *= -1 * k
			else:
				for k in rev_pos[:i]:
					p *= k
				for k in rev_negas[:5 - i]:
					p *= -1 * k
			ans.append(p)
	return max(ans)

def main():
	n = int(input())
	ans = []
	for _ in range(n):
		t = int(input())
		ans.append(solve(t, list(map(int, input().split(' ')))))
	for r in ans:
		print(r)
main()


import sys

def prod(arr, num, p):
	l = len(arr)
	pro = 1
	if p == 0:
		for h in range(num):
			pro *= arr[h]
		return pro
	else:
		ctr = 0
		for h in range(l - 1, -1, -1):
			if ctr < num:
				pro *= arr[h]
			ctr += 1
		return pro

def solve(n, a):
	pos = []
	neg = []
	zer = []
	for h in range(n):
		if a[h] > 0:
			pos.append(a[h])
		elif a[h] < 0:
			neg.append(a[h])
		else:
			zer.append(a[h])
	pos.sort()
	neg.sort()
	ans = 0
	flag = False
	pl = len(pos)
	nl = len(neg)
	zl = len(zer)
	if pl >= 5:
		val = prod(pos, 5, 1)
		if ans == False:
			ans = val
			flag = True
		else:
			ans = max(ans, val)
	if nl >= 2 and pl >= 3:
		val = prod(pos, 3, 1) * prod(neg, 2, 0)
		if ans == False:
			ans = val
			flag = True
		else:
			ans = max(ans, val)
	if nl >= 4 and pl >= 1:
		val = prod(pos, 1, 1) * prod(neg, 4, 0)
		if ans == False:
			ans = val
			flag = True
		else:
			ans = max(ans, val)
	if zl > 0:
		ans = max(ans, 0)
	ab_array = []
	for e in range(n):
		ab_array.append(abs(a[e]))
	ab_array.sort()
	val = -1 * prod(ab_array, 5, 0)
	if ans == False:
		ans = val
		flag = True
	else:
		ans = max(ans, val)
	return ans
t = int(sys.stdin.readline())
ans_arr = []
for i in range(t):
	n = int(sys.stdin.readline())
	a = [int(j) for j in sys.stdin.readline().split()]
	answer = solve(n, a)
	ans_arr.append(str(answer))
print('\n'.join(ans_arr))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(key=abs)
	pos_exists = False
	for i in a:
		if i >= 0:
			pos_exists = True
	if pos_exists:
		neg = []
		pos = []
		for i in range(n - 1, -1, -1):
			if a[i] < 0 and len(neg) < 5:
				neg.append(a[i])
			if a[i] >= 0 and len(pos) < 5:
				pos.append(a[i])
		pos.sort()
		neg.sort(key=abs)
		max_prod = -10 ** 18
		if len(pos) >= 5:
			max_prod = max(max_prod, pos[-1] * pos[-2] * pos[-3] * pos[-4] * pos[-5])
		if len(pos) >= 4 and len(neg) >= 1:
			max_prod = max(max_prod, pos[-1] * pos[-2] * pos[-3] * pos[-4] * neg[-1])
		if len(pos) >= 3 and len(neg) >= 2:
			max_prod = max(max_prod, pos[-1] * pos[-2] * pos[-3] * neg[-2] * neg[-1])
		if len(pos) >= 2 and len(neg) >= 3:
			max_prod = max(max_prod, pos[-1] * pos[-2] * neg[-3] * neg[-2] * neg[-1])
		if len(pos) >= 1 and len(neg) >= 4:
			max_prod = max(max_prod, pos[-1] * neg[-4] * neg[-3] * neg[-2] * neg[-1])
		print(max_prod)
	else:
		prod = 1
		for i in range(5):
			prod *= a[i]
		print(prod)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	ans = -1e+18
	lst.sort()
	for j in range(5):
		aa = (n - 1 + j) % n
		bb = (n - 2 + j) % n
		cc = (n - 3 + j) % n
		dd = (n - 4 + j) % n
		ee = (n - 5 + j) % n
		val = lst[aa] * lst[bb] * lst[cc] * lst[dd] * lst[ee]
		ans = max(ans, val)
	print(ans)


for i in range(int(input())):
	j = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	a1 = a[0] * a[1] * a[j - 1] * a[j - 2] * a[j - 3]
	a2 = a[0] * a[1] * a[2] * a[3] * a[j - 1]
	a3 = a[j - 4] * a[j - 5] * a[j - 1] * a[j - 2] * a[j - 3]
	ans = max([a1, a2, a3])
	print(ans)


from collections import *
from functools import *

def prod(L):
	return reduce(lambda a, b: a * b, list(L))
for T in range(int(input())):
	n = int(input())
	L = sorted(list(map(int, input().split())))
	pos = [x for x in L if x >= 0]
	neg = [x for x in L if x < 0]
	ret = -(1 << 60)
	if n == 5:
		ret = max(ret, prod(L))
	if len(pos) >= 5:
		ret = max(ret, prod(pos[-5:]))
	if len(pos) >= 3 and len(neg) >= 2:
		ret = max(ret, prod(neg[:2]) * prod(pos[-3:]))
	if len(pos) >= 1 and len(neg) >= 4:
		ret = max(ret, prod(neg[:4]) * pos[-1])
	if len(pos) == 0 and len(neg) >= 5:
		ret = max(ret, prod(neg[-5:]))
	print(ret)


for t in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	pv = []
	nv = []
	z = []
	for x in a:
		if x == 0:
			z.append(x)
		elif x > 0:
			pv.append(x)
		else:
			nv.append(x)
	if len(pv) + len(nv) < 5:
		print(0)
		continue
	if len(pv) >= 5 and len(nv) >= 0 or (len(pv) >= 3 and len(nv) >= 2) or (len(pv) >= 1 and len(nv) >= 4):
		ppos = True
		a1 = -1
		a2 = -1
		a3 = -1
		if len(pv) >= 5 and len(nv) >= 0:
			pv.sort()
			pv.reverse()
			a1 = 1
			for i in range(5):
				a1 *= pv[i]
		if len(pv) >= 3 and len(nv) >= 2:
			a2 = 1
			pv.sort()
			pv.reverse()
			for i in range(3):
				a2 *= pv[i]
			nv.sort()
			for i in range(2):
				a2 *= nv[i]
		if len(pv) >= 1 and len(nv) >= 4:
			a3 = 1
			pv.sort()
			pv.reverse()
			for i in range(1):
				a3 *= pv[i]
			nv.sort()
			for i in range(4):
				a3 *= nv[i]
		print(max(a1, a2, a3))
		continue
	elif len(z):
		print(0)
		continue
	else:
		b = [abs(x) for x in a]
		b.sort()
		print(-1 * (b[0] * b[1] * b[2] * b[3] * b[4]))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	v = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	v1 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	v2 = a[0] * a[1] * a[2] * a[3] * a[-1]
	print(max(v, v1, v2))


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = tuple(map(int, input().split()))
		if n == 5:
			print(a[0] * a[1] * a[2] * a[3] * a[4])
		elif n - a.count(0) < 5:
			print(0)
		else:
			numm = len([ea for ea in a if ea < 0])
			ap = [ea for ea in a if ea > 0]
			am = [ea for ea in a if ea < 0]
			ap.sort()
			am.sort()
			if n == numm:
				print(am[-1] * am[-2] * am[-3] * am[-4] * am[-5])
			else:
				ap = ap[-5:]
				am1n = min(4, numm)
				am1 = am[:am1n]
				am = am[am1n:]
				aa = ap + am1 + am[-3:]
				com = tuple(combinations(aa, 5))
				com0 = com[0]
				r = com0[0] * com0[1] * com0[2] * com0[3] * com0[4]
				for come in com:
					r = max(r, come[0] * come[1] * come[2] * come[3] * come[4])
				if r < 0:
					if 0 in a:
						print(0)
					else:
						print(r)
				else:
					print(r)
main()


from sys import stdin, stdout

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			n = int(R())
			a = [int(x) for x in R().split()]
			a.sort(reverse=True)
			a = ['xtra'] + a
			pos = neg = 0
			for j in range(1, n + 1):
				if a[j] < 0:
					neg += 1
				else:
					pos += 1
			POS = {}
			for j in range(1, min(6, pos + 1)):
				if j == 1:
					POS[j] = a[j]
				else:
					POS[j] = POS[j - 1] * a[j]
			NEG1 = {}
			for j in range(pos + 1, min(pos + 6, pos + neg + 1)):
				if j == pos + 1:
					NEG1[j - pos] = a[j]
				else:
					NEG1[j - pos] = NEG1[j - pos - 1] * a[j]
			NEG2 = {}
			for j in range(n, n - min(5, neg), -1):
				if j == n:
					NEG2[n - j + 1] = a[j]
				else:
					NEG2[n - j + 1] = NEG2[n - j] * a[j]
			mx = -10000000000000000000
			for j in range(pos + 1):
				if j == 0 and 5 in NEG1:
					mx = max(mx, NEG1[5])
				elif j == 5 and 5 in POS:
					mx = max(mx, POS[5])
				elif j in POS and 5 - j in NEG1:
					mx = max(mx, POS[j] * NEG1[5 - j])
			for j in range(pos + 1):
				if j == 0 and 5 in NEG2:
					mx = max(mx, NEG2[5])
				elif j == 5 and 5 in POS:
					mx = max(mx, POS[5])
				elif j in POS and 5 - j in NEG2:
					mx = max(mx, POS[j] * NEG2[5 - j])
			ans.append(str(mx))
		W('\n'.join(ans))

def main():
	s = SOLVE()
	s.solve()
main()


def ans(a, n):
	pos = 0
	neg = 0
	p = []
	n = []
	zeroes = 0
	for i in a:
		if i > 0:
			pos += 1
			p.append(i)
		elif i < 0:
			neg += 1
			n.append(i)
		else:
			zeroes += 1
	n.sort()
	p.sort(reverse=True)
	pro1 = 1
	if pos < 5:
		pro1 = -3001 ** 5
	else:
		for i in range(5):
			pro1 *= p[i]
	pro2 = 1
	if neg < 5:
		pro2 = -3001 ** 5
	else:
		for i in range(5):
			pro2 *= n[-(i + 1)]
	pro3 = 1
	if neg < 4:
		pro3 = -3001 ** 5
	else:
		for i in range(4):
			pro3 *= n[i]
	if pos == 0:
		pro3 = -3001 ** 5
	else:
		pro3 *= p[0]
	pro4 = 1
	if pos < 4:
		pro4 = -3001 ** 5
	else:
		for i in range(4):
			pro4 *= p[-(i + 1)]
	if neg == 0:
		pro4 = -3001 ** 5
	elif pos >= 4:
		pro4 *= n[-1]
	pro5 = 1
	if neg < 2:
		pro5 = -3001 ** 5
	else:
		for i in range(2):
			pro5 *= n[i]
	if pos < 3:
		pro5 = -3001 ** 5
	else:
		pro5 *= p[0] * p[1] * p[2]
	pro6 = 1
	if neg < 3:
		pro6 = -3001 ** 5
	else:
		for i in range(3):
			pro6 *= n[-(i + 1)]
	if pos <= 1:
		pro6 = -3001 ** 5
	elif neg >= 3:
		pro6 *= p[-1] * p[-2]
	if zeroes == 0:
		return max(pro1, pro2, pro3, pro4, pro5, pro6)
	else:
		return max(0, pro1, pro2, pro3, pro4, pro5, pro6)
m = int(input())
for j in range(m):
	n = int(input())
	arr = input().split()
	a = []
	for i in arr:
		a.append(int(i))
	print(ans(a, n))


t = int(input())
while t >= 1:
	n = int(input())
	s = list(map(int, input().split()))
	s = sorted(s)
	i = 1
	r1 = []
	while i <= 11:
		r = 1
		r *= s[(n - 2 + i) % n]
		r *= s[(n - 3 + i) % n]
		r *= s[(n - 4 + i) % n]
		r *= s[(n - 5 + i) % n]
		r *= s[(n - 6 + i) % n]
		r1.append(r)
		i += 1
	max1 = r1[0]
	for _ in r1:
		if _ > max1:
			max1 = _
	print(max1)
	t -= 1


import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def fast_print(input):
	sys.stdout.write(str(input) + '\n')

def multiply(numbers):
	total = 1
	for x in numbers:
		total *= x
	return total
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = get_ints()
	(pos, neg) = ([], [])
	zero = False
	for x in a:
		if x > 0:
			pos.append(x)
		else:
			neg.append(x)
		if x == 0:
			zero = True
	pos.sort(reverse=True)
	neg.sort()
	ans = float('-inf')
	p = len(pos)
	n = len(neg)
	for i in range(0, 6):
		k = min(i, p)
		l = min(5 - k, n)
		if k + l == 5:
			temp = multiply(pos[:k])
			if l == 1 or l == 3 or l == 5:
				ans = max(ans, temp * multiply(neg[-l:]))
			else:
				ans = max(ans, temp * multiply(neg[:l]))
	ans = 0 if zero and ans < 0 else ans
	fast_print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	b = [a[4], a[3], a[2], a[1], a[0], a[n - 1], a[n - 2], a[n - 3], a[n - 4], a[n - 5]]
	ans = -float('inf')
	for i in range(6):
		p = 1
		for j in range(i, i + 5):
			p *= b[j]
		ans = max(ans, p)
	print(ans)


for _ in range(int(input())):
	N = int(input())
	array = sorted([int(x) for x in input().split()])
	print(max(array[-1] * array[-2] * array[-3] * array[-4] * array[-5], array[-1] * array[-2] * array[-3] * array[0] * array[1], array[-1] * array[0] * array[1] * array[2] * array[3]))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import log2, ceil
from heapq import heappush, heappop, heapify
from copy import deepcopy
from collections import deque, Counter as CC
from bisect import bisect_left as bl

def main():
	for t in range(int(input())):
		n = int(input())
		l = [int(j) for j in input().split()]
		pos = [i for i in l if i >= 0]
		neg = [i for i in l if i < 0]
		pos.sort(reverse=True)
		neg.sort()
		m = len(neg)
		ans = -1e+18
		for i in range(min(m + 1, 6)):
			tmp = 1
			if len(pos) < 5 - i:
				continue
			for j in range(5 - i):
				tmp *= pos[j]
			if i % 2 == 0:
				for j in range(i):
					tmp *= neg[j]
			else:
				for j in range(1, i + 1):
					tmp *= neg[-j]
			ans = max(tmp, ans)
		print(ans)
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = -10000000000000000 * 3 ** 5
	l.sort()
	ans = max(ans, l[0] * l[1] * l[2] * l[3] * l[4], l[0] * l[1] * l[2] * l[3] * l[n - 1], l[0] * l[1] * l[2] * l[n - 1] * l[n - 2], l[0] * l[1] * l[n - 1] * l[n - 2] * l[n - 3], l[0] * l[n - 1] * l[n - 2] * l[n - 3] * l[n - 4], l[n - 1] * l[n - 2] * l[n - 3] * l[n - 4] * l[n - 5])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	s.reverse()
	ans = 1
	if s[0] == 0:
		print(0)
		continue
	if s[0] <= 0:
		for i in range(5):
			ans *= s[i]
		print(ans)
		continue
	s.reverse()
	i = 0
	j = n - 1
	ans *= s[j]
	j -= 1
	for e in range(2):
		l = s[i] * s[i + 1]
		r = s[j] * s[j - 1]
		if l > r:
			ans *= l
			i += 2
		else:
			ans *= r
			j -= 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	if n >= 10:
		l = 5
	else:
		l = n - 5
	if l == 0:
		b = a[:5]
	else:
		b = a[:5] + a[-l:]
	num = len(b)
	ans = []
	for i in range(num):
		for j in range(i + 1, num):
			for k in range(j + 1, num):
				for m in range(k + 1, num):
					for p in range(m + 1, num):
						temp = b[i] * b[j] * b[k] * b[m] * b[p]
						ans.append(temp)
	print(max(ans))


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
mod = int(1000000000.0) + 7
INF = float('inf')
for t in range(int(data())):
	n = int(data())
	a = sorted(mdata())
	ans = -INF
	for i in range(6):
		ans1 = 1
		for j in range(n - 5, n):
			ans1 *= a[(j + i) % n]
		ans = max(ans, ans1)
	out(ans)


[(lambda N, n: print(max(n[0] * n[1] * n[2] * n[3] * n[4], n[0] * n[1] * n[2] * n[3] * n[-1], n[0] * n[1] * n[2] * n[-2] * n[-1], n[0] * n[1] * n[-3] * n[-2] * n[-1], n[0] * n[-4] * n[-3] * n[-2] * n[-1], n[-5] * n[-4] * n[-3] * n[-2] * n[-1])))(int(input()), sorted(map(int, input().split()))) for t in range(int(input()))]


import sys
input = sys.stdin.readline

def m(A, n, k):
	A.sort()
	product = 1
	if A[n - 1] == 0 and k & 1:
		return 0
	if A[n - 1] <= 0 and k & 1:
		for i in range(n - 1, n - k - 1, -1):
			product *= A[i]
		return product
	i = 0
	j = n - 1
	if k & 1:
		product *= A[j]
		j -= 1
		k -= 1
	k >>= 1
	for itr in range(k):
		left_product = A[i] * A[i + 1]
		right_product = A[j] * A[j - 1]
		if left_product > right_product:
			product *= left_product
			i += 2
		else:
			product *= right_product
			j -= 2
	return product
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(m(a, n, 5))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	nega = [i for i in a if i < 0]
	zero = [i for i in a if i == 0]
	plus = [i for i in a if i > 0]
	nega.sort(key=lambda x: abs(x), reverse=True)
	plus.sort(reverse=True)
	if len(nega) + len(plus) < 5:
		print(0)
	elif len(plus) == 0:
		if len(zero) >= 1:
			print(0)
		else:
			print(nega[-1] * nega[-2] * nega[-3] * nega[-4] * nega[-5])
	elif len(nega) >= 4:
		if len(plus) >= 5:
			print(max(plus[0] * plus[1] * plus[2] * plus[3] * plus[4], nega[0] * nega[1] * plus[0] * plus[1] * plus[2], nega[0] * nega[1] * nega[2] * nega[3] * plus[0]))
		elif len(plus) >= 3:
			print(max(nega[0] * nega[1] * plus[0] * plus[1] * plus[2], nega[0] * nega[1] * nega[2] * nega[3] * plus[0]))
		elif len(plus) >= 1:
			print(nega[0] * nega[1] * nega[2] * nega[3] * plus[0])
		else:
			print(nega[-1] * nega[-2] * nega[-3] * nega[-4] * nega[-5] if len(zero) == 0 else 0)
	elif len(nega) >= 2:
		if len(plus) >= 5:
			print(max(plus[0] * plus[1] * plus[2] * plus[3] * plus[4], nega[0] * nega[1] * plus[0] * plus[1] * plus[2]))
		elif len(plus) >= 3:
			print(nega[0] * nega[1] * plus[0] * plus[1] * plus[2])
		else:
			print(nega[-1] * nega[-2] * nega[-3] * plus[-1] * plus[-2] if len(zero) == 0 else 0)
	elif len(plus) >= 5:
		print(plus[0] * plus[1] * plus[2] * plus[3] * plus[4])
	else:
		print(nega[-1] * plus[-1] * plus[-2] * plus[-3] * plus[-4] if len(zero) == 0 else 0)


getn = lambda : int(input())
getlist = lambda : list(map(int, input().split(' ')))

def solve():
	n = getn()
	arr = getlist()
	arr.sort()
	op1 = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	op2 = arr[-1] * arr[-2] * arr[-3] * arr[0] * arr[1]
	op3 = arr[-1] * arr[0] * arr[1] * arr[2] * arr[3]
	print(max(op1, op2, op3))
t = getn()
while t > 0:
	solve()
	t -= 1


t = int(input())
for z in range(t):
	n = int(input())
	s = input()
	s = s.split()
	a = []
	for i in range(n):
		a.append(int(s[i]))
	a.sort()
	ans = -9223372036854775808
	temp = 1
	for i in range(-5, 0):
		temp *= a[i]
	if temp > ans:
		ans = temp
	temp = 1
	for i in range(2):
		temp *= a[i]
	for i in range(-3, 0):
		temp *= a[i]
	if temp > ans:
		ans = temp
	temp = 1
	for i in range(4):
		temp *= a[i]
	for i in range(-1, 0):
		temp *= a[i]
	if temp > ans:
		ans = temp
	print(ans)


import sys
import math
from decimal import *

def I():
	return int(sys.stdin.readline())

def IL():
	return list(map(int, sys.stdin.readline().strip().split()))

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve():
	tt = I()
	for ii in range(tt):
		n = I()
		l = IL()
		l.sort()
		an1 = l[0] * l[1] * l[-1] * l[-2] * l[-3]
		an2 = l[0] * l[1] * l[2] * l[3] * l[-1]
		an3 = l[-5] * l[-4] * l[-3] * l[-2] * l[-1]
		ans = max(an1, an2, an3)
		print(ans)
		pass
solve()


for _ in range(int(input())):
	n = int(input())
	pos = []
	neg = []
	all = []
	ans = 1
	flag = 0
	for x in list(map(int, input().split())):
		ans *= x
		if x == 0:
			flag = 1
		if x < 0:
			neg.append(-x)
		else:
			pos.append(x)
		all.append(abs(x))
	ans = []
	pos.sort(reverse=True)
	neg.sort(reverse=True)
	all.sort()
	if len(pos) >= 5:
		tmp = 1
		for i in range(5):
			tmp *= pos[i]
		ans.append(tmp)
	if len(pos) >= 2:
		tmp = 1
		for i in range(5):
			tmp *= all[i]
		ans.append(-tmp)
	if len(pos) >= 3:
		tmp = 1
		for i in range(3):
			tmp *= pos[i]
		if len(neg) >= 2:
			tmp = tmp * neg[0] * neg[1]
			ans.append(tmp)
	if len(pos) >= 1:
		tmp = pos[0]
		if len(neg) >= 4:
			for i in range(4):
				tmp *= neg[i]
			ans.append(tmp)
	tmp = 1
	for i in range(5):
		tmp *= all[i]
	ans.append(-tmp)
	ans.sort(reverse=True)
	if flag == 1:
		ans[0] = max(ans[0], 0)
	print(ans[0])


n = int(input().strip())
for i in range(n):
	input()
	a = sorted([int(i) for i in input().strip().split()])
	print(max(a[-1] * a[-2] * a[-3] * a[-4] * a[-5], a[-1] * a[-2] * a[-3] * a[1] * a[0], a[-1] * a[3] * a[2] * a[1] * a[0]))


for t in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	i = 0
	j = n - 1
	if a[j] == 0:
		print(0)
	else:
		c = a[j]
		j -= 1
		for k in range(2):
			p1 = a[i] * a[i + 1]
			p2 = a[j] * a[j - 1]
			if p1 * c >= p2 * c:
				c *= p1
				i += 2
			else:
				c *= p2
				j -= 2
		print(c)


testcases = int(input())
for testcase in range(testcases):
	n = int(input())
	temparr = input()
	temparr = temparr.split()
	arr = []
	for i in temparr:
		arr.append(int(i))
	arr = sorted(arr)
	ans = 0
	curans = 1
	for i in range(n - 5, n):
		curans *= arr[i]
	ans = curans
	if n == 5:
		print(ans)
		continue
	curans = 1
	for i in range(0, 4):
		curans *= arr[i]
	curans *= arr[-1]
	if curans > ans:
		ans = curans
	curans = 1
	for i in range(0, 2):
		curans *= arr[i]
	curans *= arr[-1]
	curans *= arr[-2]
	curans *= arr[-3]
	if curans > ans:
		ans = curans
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	tem = input()
	tem = tem.split(' ')
	num = []
	for j in range(n):
		num += [int(tem[j])]
	num.sort()
	ans = -30000.0 ** 5
	tem = 1
	for j in range(6):
		tem = 1
		for k in range(5):
			tem *= num[k - j]
		ans = max(ans, tem)
	print(ans)


for t in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	ans = []
	ans.append(l[-1] * l[-2] * l[-3] * l[-4] * l[-5])
	ans.append(l[0] * l[1] * l[-1] * l[-2] * l[-3])
	ans.append(l[0] * l[1] * l[2] * l[3] * l[-1])
	ans.append(l[0] * l[1] * l[2] * l[3] * l[4])
	print(max(ans))


from functools import reduce
from operator import mul
for _ in range(int(input())):
	a = int(input())
	b = input()
	t = sorted(map(int, b.split()))
	print(max((reduce(mul, t[:i], 1) * reduce(mul, t[i - 5:], 1) for i in range(5))))


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr = sorted(arr)
	pos = 0
	neg = 0
	point = n
	for i in range(n):
		if arr[i] >= 0:
			pos += 1
		else:
			neg += 1
	ans = float('-inf')
	for j in range(n):
		if arr[j] >= 0:
			point = j
			break
	if pos >= 5:
		prod = 1
		for j in range(n - 1, n - 6, -1):
			prod *= arr[j]
		ans = max(ans, prod)
	if neg >= 1 and pos >= 4:
		prod = arr[point - 1]
		prod = arr[point] * arr[point + 1] * arr[point + 2] * arr[point + 3] * prod
		ans = max(ans, prod)
	if neg >= 2 and pos >= 3:
		prod = arr[0] * arr[1]
		prod = arr[-1] * arr[-2] * arr[-3] * prod
		ans = max(ans, prod)
	if neg >= 3 and pos >= 2:
		prod = arr[point - 1] * arr[point - 2] * arr[point - 3]
		prod = prod * arr[-1] * arr[-2]
		ans = max(ans, prod)
	if neg >= 4 and pos >= 1:
		prod = 1
		for j in range(4):
			prod *= arr[j]
		prod *= arr[-1]
		ans = max(ans, prod)
	if neg >= 5:
		prod = 1
		for j in range(point - 1, point - 6, -1):
			prod *= arr[j]
		ans = max(ans, prod)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	a = l[0] * l[1] * l[2] * l[3] * l[4]
	b = l[0] * l[1] * l[2] * l[n - 1] * l[n - 2]
	c = l[0] * l[n - 1] * l[n - 2] * l[n - 3] * l[n - 4]
	print(max(a, max(b, c)))


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True

def mul(arr):
	p = 1
	for i in arr:
		p *= i
	return p
for _ in range(int(inp())):
	n = int(inp())
	arr = lmp()
	nz = 0
	(nnl, npl) = ([], [])
	for i in range(n):
		if arr[i] > 0:
			npl.append(arr[i])
		elif arr[i] == 0:
			nz += 1
		else:
			nnl.append(arr[i])
	np = len(npl)
	nn = len(nnl)
	npl.sort(reverse=True)
	nnl.sort()
	ans = -inf
	if nz:
		ans = 0
	if nn > 4:
		ans = max(ans, mul(nnl[-5:]))
	if nn > 3 and np > 0:
		ans = max(ans, npl[0] * mul(nnl[:4]))
	if np > 1 and nn > 2:
		ans = max(ans, mul(npl[:2]) * mul(nnl[-3:]))
	if np > 2 and nn > 1:
		ans = max(ans, mul(npl[:3]) * mul(nnl[:2]))
	if np > 3 and nn > 0:
		ans = max(ans, mul(npl[:4]) * nnl[-1])
	if np > 4:
		ans = max(ans, mul(npl[:5]))
	print(ans)


def calc(p, m):
	ret2 = -100000000000000000000
	lenp = len(p)
	lenm = len(m)
	for i in range(6):
		j = 5 - i
		if i > lenp:
			continue
		if j > lenm:
			continue
		ret = 1
		for k in range(i):
			ret *= p[k]
		for k in range(j):
			ret *= m[k]
		ret2 = max(ret2, ret)
	return ret2

def main(N, A):
	m = []
	p = []
	for a in A:
		if a >= 0:
			p.append(a)
		else:
			m.append(a)
	m.sort()
	p.sort()
	ret = -100000000000000000000
	ret = max(ret, calc(p, m))
	ret = max(ret, calc(p[::-1], m))
	ret = max(ret, calc(p, m[::-1]))
	ret = max(ret, calc(p[::-1], m[::-1]))
	return ret
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	print(main(N, A))


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = max(a[-1] * a[-2] * a[-3] * a[-4] * a[-5], a[-1] * a[-2] * a[-3] * a[0] * a[1], a[-1] * a[0] * a[1] * a[2] * a[3])
	print(ans)


def prod(A):
	c = 1
	for items in A:
		c *= items
	return c
for _ in range(int(input())):
	n = int(input())
	A = sorted([int(_) for _ in input().split()])
	x = prod(A[-5:])
	y = prod(A[:2]) * prod(A[-3:])
	z = prod(A[:4]) * prod(A[-1:])
	print(max(x, y, z))


import itertools
import math
import sys
from collections import defaultdict

def stdinWrapper():
	data = '4\n5\n-1 -2 -3 -4 -5\n6\n-1 -2 -3 1 2 -1\n6\n-1 0 0 0 -1 -1\n6\n-9 -7 -5 -3 -2 1\n\n\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield input()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def solve(a):
	a = sorted(a)

	def prod(data):
		res = 1
		for x in data:
			res *= x
		return res
	cases = [a[-3:] + a[:2], a[-5:], a[:4] + a[-1:]]
	return max([prod(x) for x in cases])
t = getType(int)
for _ in range(t):
	n = getType(int)
	a = getArray(int)
	res = solve(a)
	print(res)


t = int(input())
for hh in range(0, t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	mx = -1000000000000000000
	for i in range(4, -2, -1):
		prod = 1
		for j in range(i, i - 5, -1):
			prod = prod * a[j]
		mx = max(mx, prod)
	print(mx)


from math import *
from collections import *
from itertools import *
from functools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)

def maxProductSubarrayOfSizeK(A, n, k):
	A.sort()
	product = 1
	if A[n - 1] == 0 and k & 1:
		return 0
	if A[n - 1] <= 0 and k & 1:
		for i in range(n - 1, n - k - 1, -1):
			product *= A[i]
		return product
	i = 0
	j = n - 1
	if k & 1:
		product *= A[j]
		j -= 1
		k -= 1
	k >>= 1
	for itr in range(k):
		left_product = A[i] * A[i + 1]
		right_product = A[j] * A[j - 1]
		if left_product > right_product:
			product *= left_product
			i += 2
		else:
			product *= right_product
			j -= 2
	return product
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	print(maxProductSubarrayOfSizeK(l, n, 5))


for test in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split(' ')]
	l.sort()
	a = l[-5] * l[-4] * l[-3] * l[-2] * l[-1]
	b = l[0] * l[1] * l[-3] * l[-2] * l[-1]
	c = l[0] * l[1] * l[2] * l[3] * l[-1]
	print(max([a, b, c]))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	l = []
	l.append(s[-1] * s[-2] * s[-3] * s[-4] * s[-5])
	l.append(s[-1] * s[-2] * s[-3] * s[0] * s[1])
	l.append(s[0] * s[1] * s[2] * s[3] * s[-1])
	print(max(l))


INF = float('inf')

def prod(arr):
	ret = 1
	for x in arr:
		ret *= x
	return ret

def tc():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = -INF
	for top in range(6):
		if top == 0:
			tmp = prod(a[:5])
		elif top == 5:
			tmp = prod(a[-5:])
		else:
			tmp = prod(a[-top:]) * prod(a[:5 - top])
		ans = max(tmp, ans)
	print(ans)
T = int(input())
for _ in range(T):
	tc()


from sys import stdin, stdout
from math import gcd, log2, log10, floor, ceil
import math
from collections import defaultdict, OrderedDict
from bisect import bisect_left

def function(pos, neg, noofpos):
	res = 1
	if noofpos == 0:
		for i in range(5):
			a = max(neg)
			neg.remove(a)
			res *= a
		return res
	for i in range(noofpos):
		a = max(pos)
		res *= a
		pos.remove(a)
	for i in range(5 - noofpos):
		if len(neg) == 0:
			return float('-inf')
		a = min(neg)
		res *= a
		neg.remove(a)
	return res

def fun(pos, neg, n):
	if n == 5:
		res = 1
		for i in pos:
			res *= i
		for i in neg:
			res *= i
		return res
	if len(pos) == 0:
		return function(pos, neg, 0)
	if len(neg) == 0:
		return function(pos.copy(), neg.copy(), 5)
	if len(pos) <= 2:
		return function(pos, neg, 1)
	if len(pos) <= 4:
		return max(function(pos.copy(), neg.copy(), 3), function(pos.copy(), neg.copy(), 1))
	return max(function(pos.copy(), neg.copy(), 3), function(pos.copy(), neg.copy(), 1), function(pos.copy(), neg.copy(), 5))
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	pos = []
	neg = []
	for i in a:
		if i < 0:
			neg.append(i)
		else:
			pos.append(i)
	neg.sort()
	pos.sort()
	ans = fun(pos, neg, n)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	inp = list(map(int, input().split()))
	inp.sort()
	ans = inp[n - 1] * inp[n - 2] * inp[n - 3] * inp[n - 4] * inp[n - 5]
	ans1 = inp[n - 1] * inp[0] * inp[1] * inp[2] * inp[3]
	ans2 = inp[n - 1] * inp[n - 2] * inp[n - 3] * inp[0] * inp[1]
	print(max(ans, ans1, ans2))


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	pos = []
	neg = []
	for val in arr:
		if val < 0:
			neg.append(val)
		else:
			pos.append(val)
	neg.sort()
	pos.sort(reverse=True)
	ans = []
	if len(pos) >= 5:
		ans.append(pos[0] * pos[1] * pos[2] * pos[3] * pos[4])
	if len(pos) >= 4 and len(neg) >= 1:
		ans.append(pos[0] * pos[1] * pos[2] * pos[3] * neg[-1])
	if len(pos) >= 3 and len(neg) >= 2:
		ans.append(pos[0] * pos[1] * pos[2] * neg[0] * neg[1])
	if len(pos) >= 2 and len(neg) >= 3:
		ans.append(pos[0] * pos[1] * neg[-3] * neg[-2] * neg[-1])
	if len(pos) >= 1 and len(neg) >= 4:
		ans.append(pos[0] * neg[0] * neg[1] * neg[2] * neg[3])
	if len(neg) >= 5:
		ans.append(neg[-5] * neg[-4] * neg[-3] * neg[-2] * neg[-1])
	print(max(ans))
for _ in range(int(input())):
	solve()


t = int(input())

def multiply(arr):
	p = 1
	for v in arr:
		p *= v
	return p
for i in range(t):
	n = int(input())
	s = [int(v) for v in input().split()]
	s.sort()
	p = multiply(s[-5:])
	for i in range(1, 5):
		p = max(p, multiply(s[:i] + s[-5 + i:]))
	print(p)


def solve(n, a):
	a.sort()
	ans = float('-inf')
	for i in range(5):
		p1 = (i - 1) % n
		p2 = (i - 2) % n
		p3 = (i - 3) % n
		p4 = (i - 4) % n
		p5 = (i - 5) % n
		val = a[p1] * a[p2] * a[p3] * a[p4] * a[p5]
		ans = max(ans, val)
	return ans
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(n, a))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
for _ in range(L()[0]):
	n = L()[0]
	A = L()
	A.sort()
	p1 = -10 ** 20
	for i in range(6):
		mul = 1
		for j in range(i):
			mul *= A[j]
		for j in range(5 - i):
			mul *= A[n - j - 1]
		p1 = max(p1, mul)
	print(p1)
endtime = time.time()


import sys
import os

def changeStdioToFile():
	path = os.path.dirname(os.path.abspath(__file__))
	sys.stdin = open(f'{path}/input.txt', 'r')
	sys.stdout = open(f'{path}/output.txt', 'w')
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	res2 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	res3 = a[-1] * a[0] * a[1] * a[2] * a[3]
	res4 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	res5 = a[0] * a[-1] * a[-2] * a[-3] * a[-4]
	a = [res2, res3, res4, res5]
	print(max(a))


import sys
import math
from math import *
from collections import Counter, defaultdict, deque
lip = lambda : list(map(int, input().split()))
ip = lambda : int(input())
sip = lambda : input().split()

def main():
	n = ip()
	arr = lip()
	arr.sort()
	f = 0
	ls = n - 1
	temp1 = []
	prod = 1
	for i in range(5):
		prod *= arr[i]
		temp1.append(prod)
	temp2 = []
	prod = 1
	for i in range(n - 1, n - 5 - 1, -1):
		prod *= arr[i]
		temp2.append(prod)
	mx = max(temp2[-1], temp1[-1])
	i = 0
	j = 3
	while j >= 0:
		mx = max(mx, temp1[i] * temp2[j])
		j -= 1
		i += 1
	print(mx)
for i in range(ip()):
	main()


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
for _ in range(inn()):
	n = inn()
	a = arr()
	a.sort()
	ans = -999999999999999999999
	for i in range(5):
		l = a[:i] + a[n - 5 + i:]
		val = 1
		for i in l:
			val *= i
		ans = max(ans, val)
	print(ans)


from collections import *
from heapq import *
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	nn = 0
	for e in arr:
		if e < 0:
			nn += 1
	ans = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	if nn >= 2:
		ans = max(ans, arr[-1] * arr[-2] * arr[-3] * arr[1] * arr[0])
	if nn >= 4:
		ans = max(ans, arr[-1] * arr[3] * arr[2] * arr[1] * arr[0])
	print(ans)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
INF = 10 ** 20
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	MINDP = [INF, INF, INF, INF, INF]
	MAXDP = [INF, INF, INF, INF, INF]
	for i in range(n):
		if MINDP[3] != INF and (MINDP[4] == INF or min(MINDP[3] * a[i], MAXDP[3] * a[i]) < MINDP[4]):
			MINDP[4] = min(MINDP[3] * a[i], MAXDP[3] * a[i])
		if MAXDP[3] != INF and (MAXDP[4] == INF or max(MINDP[3] * a[i], MAXDP[3] * a[i]) > MAXDP[4]):
			MAXDP[4] = max(MINDP[3] * a[i], MAXDP[3] * a[i])
		if MINDP[2] != INF and (MINDP[3] == INF or min(MINDP[2] * a[i], MAXDP[2] * a[i]) < MINDP[3]):
			MINDP[3] = min(MINDP[2] * a[i], MAXDP[2] * a[i])
		if MAXDP[2] != INF and (MAXDP[3] == INF or max(MINDP[2] * a[i], MAXDP[2] * a[i]) > MAXDP[3]):
			MAXDP[3] = max(MINDP[2] * a[i], MAXDP[2] * a[i])
		if MINDP[1] != INF and (MINDP[2] == INF or min(MINDP[1] * a[i], MAXDP[1] * a[i]) < MINDP[2]):
			MINDP[2] = min(MINDP[1] * a[i], MAXDP[1] * a[i])
		if MAXDP[1] != INF and (MAXDP[2] == INF or max(MINDP[1] * a[i], MAXDP[1] * a[i]) > MAXDP[2]):
			MAXDP[2] = max(MINDP[1] * a[i], MAXDP[1] * a[i])
		if MINDP[0] != INF and (MINDP[1] == INF or min(MINDP[0] * a[i], MAXDP[0] * a[i]) < MINDP[1]):
			MINDP[1] = min(MINDP[0] * a[i], MAXDP[0] * a[i])
		if MAXDP[0] != INF and (MAXDP[1] == INF or max(MINDP[0] * a[i], MAXDP[0] * a[i]) > MAXDP[1]):
			MAXDP[1] = max(MINDP[0] * a[i], MAXDP[0] * a[i])
		if MINDP[0] == INF or MINDP[0] > a[i]:
			MINDP[0] = a[i]
		if MAXDP[0] == INF or MAXDP[0] < a[i]:
			MAXDP[0] = a[i]
	print(MAXDP[4])


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	ans = max(arr[0] * arr[1] * arr[2] * arr[3] * arr[4], arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[0], arr[-1] * arr[-2] * arr[0] * arr[1] * arr[2])
	print(ans)


def prod(lst):
	p = 1
	for i in lst:
		p = p * i
	return p
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	a.sort()
	pr = prod(a[:2] + a[-3:])
	pr1 = prod(a[:4] + a[-1:])
	pr2 = prod(a[-5:])
	pr = max(pr, pr1, pr2)
	print(pr)


import sys, math
try:
	(sys.stdin, sys.stdout) = (open('input.txt', 'r'), open('out.txt', 'w'))
except:
	pass
from sys import stdin, stdout
mod = int(1000000000.0 + 7)
from statistics import mode
from collections import *
from math import ceil, floor, inf, factorial, gcd, log2, sqrt, log
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()

def lcm(a, b):
	return a * b // gcd(a, b)

def setbits(n):
	return bin(n).count('1')

def resetbits(n):
	return bin(n).count('0')

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r):
	(num, den) = (1, 1)
	r = min(n, n - r)
	for i in range(r):
		num *= n - i
		den *= i + 1
	return num // den

def ncr_p(n, r, p):
	(num, den) = (1, 1)
	r = min(r, n - r)
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * modinv(den, p) % p

def isPrime(num):
	if num <= 1:
		return False
	if num == 2 or n == 3:
		return True
	if num % 2 == 0 or num % 3 == 0:
		return False
	m = int(num ** 0.5) + 1
	for i in range(5, m, 6):
		if num % i == 0 or num % (i + 2) == 0:
			return False
	return True

def bin_search(s, low, high, val):
	while low <= high:
		mid = low + (high - low) // 2
		if s[mid] == val:
			return mid
		elif s[mid] < val:
			low = mid + 1
		else:
			high = mid - 1
	return -1

def sumofdigit(num):
	count = 0
	while num:
		count += num % 10
		num //= 10
	return count

def inputmatrix():
	(r, c) = iia()
	mat = [0] * r
	for i in range(r):
		mat[i] = iia()
	return (r, c, mat)

def prefix_sum(n, s):
	for i in range(1, n):
		s[i] += s[i - 1]
	return s

def binomial(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def divisors(n):
	res = []
	for i in range(1, ceil(sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				res.append(i)
			else:
				res.append(i)
				res.append(n // i)
	return res

def fun(arr):
	n = len(arr)
	ans = -inf
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				for l in range(k + 1, n):
					for m in range(l + 1, n):
						ans = max(ans, arr[i] * arr[j] * arr[k] * arr[l] * arr[m])
	return ans
for _ in range(ii1()):
	n = ii1()
	arr = iia()
	if n == 5:
		prod = 1
		for i in arr:
			prod *= i
		print(prod)
	else:
		arr.sort()
		product = []
		for i in range(5):
			if i > n - i - 1:
				break
			if i == n - 1 - i:
				product.append(arr[i])
			else:
				product.append(arr[i])
				product.append(arr[-(i + 1)])
		ans = 0
		ans = fun(product)
		print(ans)


import math
for i in range(int(input())):
	n = input()
	a = sorted(map(int, input().split()))
	print(max((math.prod(a[:i] + a[i - 5:]) for i in (0, 2, 4))))


num_cases = int(input())
for case in range(num_cases):
	num_ints = int(input())
	ints = [int(n) for n in input().split()]
	ints = sorted(ints)
	min = ints[0]
	max = ints[-1]
	if max < 0:
		ans = 1
		for i in range(1, 6):
			ans *= ints[-i]
	elif min > 0:
		ans = 1
		for i in range(1, 6):
			ans *= ints[-i]
	else:
		neg_count = 0
		for i in range(5):
			if ints[i] < 0:
				neg_count += 1
			else:
				break
		pos_count = 0
		for i in range(1, 6):
			if ints[-i] > 0:
				pos_count += 1
			else:
				break
		if neg_count >= 4:
			ans_1 = 1
			for i in range(4):
				ans_1 *= ints[i]
			ans_1 *= max
			ans_2 = 1
			for i in range(2):
				ans_2 *= ints[i]
			for i in range(1, 4):
				ans_2 *= ints[-i]
			ans_3 = 1
			for i in range(1, 6):
				ans_3 *= ints[-i]
			answers = [ans_1, ans_2, ans_3]
			ans = sorted(answers)[-1]
		elif neg_count >= 2:
			ans_1 = 1
			for i in range(2):
				ans_1 *= ints[i]
			for i in range(1, 4):
				ans_1 *= ints[-i]
			ans_2 = 1
			for i in range(1, 6):
				ans_2 *= ints[-i]
			ans = sorted([ans_1, ans_2])[-1]
		elif neg_count >= 0:
			ans = 1
			for i in range(1, 6):
				ans *= ints[-i]
	print(ans)


t = int(input())
for _ in range(t):
	x = 0
	k = 0
	n = int(input())
	v = list(map(int, input().split()))
	v.sort()
	for i in range(len(v)):
		if v[i] > 0:
			break
	if i >= 4:
		x = max(v[0] * v[1] * v[2] * v[3] * v[-1], v[0] * v[1] * v[-3] * v[-2] * v[-1], v[-5] * v[-4] * v[-3] * v[-2] * v[-1])
	elif i >= 2:
		x = max(v[0] * v[1] * v[-3] * v[-2] * v[-1], v[-5] * v[-4] * v[-3] * v[-2] * v[-1])
	else:
		x = v[-5] * v[-4] * v[-3] * v[-2] * v[-1]
	print(x)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	n = N()
	a = RLL()
	lma = [0] * n
	lmi = [0] * n
	(rma, rmi) = ([0] * n, [0] * n)
	(ma, mi) = (max(a[0], a[1]), min(a[0], a[1]))
	lma[1] = ma * mi
	lmi[1] = ma * mi
	for i in range(2, n - 3):
		lma[i] = max(lma[i - 1], a[i] * ma, a[i] * mi)
		lmi[i] = min(lmi[i - 1], a[i] * ma, a[i] * mi)
		ma = max(ma, a[i])
		mi = min(mi, a[i])
	(ma, mi) = (max(a[-1], a[-2]), min(a[-1], a[-2]))
	rma[-2] = ma * mi
	rmi[-2] = ma * mi
	for i in range(n - 3, 2, -1):
		rma[i] = max(rma[i + 1], a[i] * ma, a[i] * mi)
		rmi[i] = min(rmi[i + 1], a[i] * ma, a[i] * mi)
		ma = max(ma, a[i])
		mi = min(mi, a[i])
	ans = -float('inf')
	for i in range(2, n - 2):
		ans = max(ans, a[i] * lma[i - 1] * rma[i + 1], a[i] * lmi[i - 1] * rma[i + 1], a[i] * lma[i - 1] * rmi[i + 1], a[i] * lmi[i - 1] * rmi[i + 1])
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	neg = []
	pos = []
	for x in a:
		if x < 0:
			neg.append(x)
		else:
			pos.append(x)
	neg.sort(reverse=True)
	pos.sort()
	print(max(pos[-1] * pos[-2] * pos[-3] * pos[-4] * pos[-5] if len(pos) >= 5 and len(neg) >= 0 else float('-inf'), neg[0] * pos[0] * pos[1] * pos[2] * pos[3] if len(pos) >= 4 and len(neg) >= 1 else float('-inf'), neg[-1] * neg[-2] * pos[-1] * pos[-2] * pos[-3] if len(pos) >= 3 and len(neg) >= 2 else float('-inf'), neg[0] * neg[1] * neg[2] * pos[0] * pos[1] if len(pos) >= 2 and len(neg) >= 3 else float('-inf'), neg[-1] * neg[-2] * neg[-3] * neg[-4] * pos[-1] if len(pos) >= 1 and len(neg) >= 4 else float('-inf'), neg[0] * neg[1] * neg[2] * neg[3] * neg[4] if len(pos) >= 0 and len(neg) >= 5 else float('-inf')))


inf = 1000000000000000000000000
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	dp = [[[-inf, inf] for j in range(5)] for i in range(n)]
	dp[0][0] = [a[0], a[0]]
	for i in range(n - 1):
		dp[i + 1][0] = [a[i + 1], a[i + 1]]
		for j in range(5):
			dp[i + 1][j][0] = max(dp[i][j][0], dp[i + 1][j][0])
			dp[i + 1][j][1] = min(dp[i][j][1], dp[i + 1][j][1])
		for j in range(4):
			if dp[i][j][0] != -inf:
				dp[i + 1][j + 1][0] = max(dp[i + 1][j + 1][0], dp[i][j][0] * a[i + 1])
				dp[i + 1][j + 1][1] = min(dp[i + 1][j + 1][1], dp[i][j][0] * a[i + 1])
			if dp[i][j][1] != inf:
				dp[i + 1][j + 1][0] = max(dp[i + 1][j + 1][0], dp[i][j][1] * a[i + 1])
				dp[i + 1][j + 1][1] = min(dp[i + 1][j + 1][1], dp[i][j][1] * a[i + 1])
	print(dp[n - 1][4][0])


for testcase in range(int(input())):
	n = int(input())
	vals = sorted(map(int, input().split()))
	neg_4_pos_1 = vals[0] * vals[1] * vals[2] * vals[3] * vals[-1]
	neg_2_pos_3 = vals[0] * vals[1] * vals[-1] * vals[-2] * vals[-3]
	all_neg_pos = vals[-1] * vals[-2] * vals[-3] * vals[-4] * vals[-5]
	print(max(neg_4_pos_1, neg_2_pos_3, all_neg_pos))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	a.sort()
	p1 = a[0] * a[1] * a[2] * a[3] * a[-1]
	p2 = a[0] * a[1] * a[-3] * a[-2] * a[-1]
	p3 = a[-5] * a[-4] * a[-3] * a[-2] * a[-1]
	ans = max(p1, p2, p3)
	print(ans)


import collections
for t in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	arr = sorted(num)
	val = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	out = val
	val = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	out = max(out, val)
	val = arr[0] * arr[1] * arr[2] * arr[-2] * arr[-1]
	out = max(out, val)
	val = arr[0] * arr[1] * arr[-3] * arr[-2] * arr[-1]
	out = max(out, val)
	val = arr[0] * arr[-4] * arr[-3] * arr[-2] * arr[-1]
	out = max(out, val)
	val = arr[-5] * arr[-4] * arr[-3] * arr[-2] * arr[-1]
	out = max(out, val)
	print(out)


import sys
input = sys.stdin.readline

def ff(l, N):
	if N == 5:
		r = 1
		for i in range(N):
			r *= l[i]
		return r
	c = 0
	m = 0
	ll = []
	for x in l:
		if x == 0:
			c += 1
		else:
			if x < 0:
				m += 1
			ll.append(x)
	N -= c
	if N < 5:
		return 0
	if m == N:
		if c == 0:
			ll.sort()
			R = 1
			for i in range(5):
				R *= ll.pop()
			return R
		return 0
	if N == 5:
		r = 1
		for i in range(N):
			r *= ll[i]
		return max(r, 0)
	(l1, l2) = ([], [])
	for x in ll:
		if x > 0:
			l1.append(x)
		else:
			l2.append(x)
	l1.sort()
	l2.sort()
	l2 = l2[::-1]
	R = l1.pop()
	y = []
	while len(l1) >= 2:
		x = l1.pop()
		x *= l1.pop()
		y.append(x)
	while len(l2) >= 2:
		x = l2.pop()
		x *= l2.pop()
		y.append(x)
	y.sort()
	R = R * y[-1] * y[-2]
	return R
(T,) = map(int, input().split())
for _ in range(T):
	(N,) = map(int, input().split())
	X = list(map(int, input().split()))
	print(ff(X, N))


def maxProduct(arr, n):
	arr.sort()
	m0 = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	m1 = arr[0] * arr[1] * arr[2] * arr[3] * arr[n - 1]
	m2 = arr[0] * arr[1] * arr[2] * arr[n - 2] * arr[n - 1]
	m3 = arr[0] * arr[1] * arr[n - 3] * arr[n - 2] * arr[n - 1]
	m4 = arr[0] * arr[n - 4] * arr[n - 3] * arr[n - 2] * arr[n - 1]
	m5 = arr[n - 5] * arr[n - 4] * arr[n - 3] * arr[n - 2] * arr[n - 1]
	return max(m1, m2, m3, m4, m0, m5)
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(maxProduct(arr, n))


def input_int():
	return int(input())

def input_int_list():
	return list(map(int, input().split()))

def input_int_map():
	return map(int, input().split())
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)

def run():
	q_num = input_int()
	for i in range(q_num):
		num_count = input_int()
		nums = input_int_list()
		nums.sort()
		p1 = nums[0:4] + [nums[-1]]
		p2 = nums[0:2] + nums[num_count - 3:num_count]
		p3 = nums[num_count - 5:num_count]
		r1 = prod(p1)
		r2 = prod(p2)
		r3 = prod(p3)
		print(max(r1, r2, r3))
run()


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))[:n]
	a.sort()
	net = []
	for i in range(n):
		aa = a[(n - 1 + i) % n]
		bb = a[(n - 2 + i) % n]
		cc = a[(n - 3 + i) % n]
		dd = a[(n - 4 + i) % n]
		ee = a[(n - 5 + i) % n]
		high = aa * bb * cc * dd * ee
		net.append(high)
	print(max(net))
	t -= 1


from functools import reduce

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	(ng, ps) = ([], [])
	for i in a:
		if i < 0:
			ng.append(-i)
		else:
			ps.append(i)
	ps.sort(reverse=True)
	ng.sort(reverse=True)
	ans = max(reduce(int.__mul__, ps[:5]) if len(ps) >= 5 else -10 ** 30, reduce(int.__mul__, ps[:3] + ng[:2]) if len(ps) >= 3 and len(ng) >= 2 else -10 ** 30, reduce(int.__mul__, ps[:1] + ng[:4]) if len(ps) >= 1 and len(ng) >= 4 else -10 ** 30)
	if 0 in a:
		ans = max(ans, 0)
	ps.sort()
	ng.sort()
	ans = max(ans, -reduce(int.__mul__, ps[:4] + ng[:1]) if len(ps) >= 4 and len(ng) >= 1 else -10 ** 30, -reduce(int.__mul__, ps[:2] + ng[:3]) if len(ps) >= 2 and len(ng) >= 3 else -10 ** 30, -reduce(int.__mul__, ng[:5]) if len(ng) >= 5 else -10 ** 30)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	p = []
	o = []
	for i in l:
		if i < 0:
			o.append(-1 * i)
		else:
			p.append(i)
	p.sort(reverse=True)
	o.sort(reverse=True)
	l.sort(reverse=True)
	e = []
	if len(p) >= 5:
		ans = p[0] * p[1] * p[2] * p[3] * p[4]
		e.append(ans)
	if len(p) >= 3 and len(o) >= 2:
		ans = p[0] * p[1] * p[2] * o[0] * o[1]
		e.append(ans)
	if len(p) >= 1 and len(o) >= 4:
		ans = o[0] * o[1] * o[2] * o[3] * p[0]
		e.append(ans)
	ans = l[0] * l[1] * l[2] * l[3] * l[4]
	e.append(ans)
	print(max(e))


import sys

def Ints():
	return map(int, sys.stdin.readline().strip().split())

def Strs():
	return map(str, sys.stdin.readline().strip().split())

def Array():
	return list(map(int, sys.stdin.readline().strip().split()))

def Str():
	return sys.stdin.readline().strip()

def Int():
	return int(sys.stdin.readline().strip())

def MOD():
	return 1000000007

def power(base, power):
	MOD = 1000000007
	result = 1
	while power > 0:
		if power % 2 == 1:
			result = result * base % MOD
		power = power // 2
		base = base * base % MOD
	return result
t = Int()
while t:
	n = Int()
	a = Array()
	positive = []
	negative = []
	for i in range(n):
		if a[i] < 0:
			negative.append(a[i])
		else:
			positive.append(a[i])
	positive = sorted(positive, reverse=True)
	negative = sorted(negative)
	if len(negative) + len(positive) == 5:
		print(a[0] * a[1] * a[2] * a[3] * a[4])
	elif len(negative) == 0:
		print(positive[0] * positive[1] * positive[2] * positive[3] * positive[4])
	elif len(positive) == 0:
		print(negative[-1] * negative[-2] * negative[-3] * negative[-4] * negative[-5])
	else:
		res = -float('inf')
		if len(positive) >= 5:
			res = max(res, positive[0] * positive[1] * positive[2] * positive[3] * positive[4])
		if len(negative) >= 4 and len(positive) >= 1:
			res = max(res, negative[0] * negative[1] * negative[2] * negative[3] * positive[0])
		if len(negative) >= 3 and len(positive) >= 2:
			res = max(res, negative[0] * negative[1] * negative[2] * positive[0] * positive[1])
		if len(negative) >= 2 and len(positive) >= 3:
			res = max(res, negative[0] * negative[1] * positive[0] * positive[1] * positive[2])
		if len(negative) >= 1 and len(positive) >= 4:
			res = max(res, negative[0] * positive[0] * positive[1] * positive[2] * positive[3])
		if len(negative) >= 5:
			res = max(res, negative[0] * negative[1] * negative[2] * negative[3] * negative[4])
		print(res)
	t -= 1


from sys import stdin
for _ in ' ' * int(stdin.readline()):
	a = int(stdin.readline())
	b = sorted(map(int, stdin.readline().split()))
	print(max(b[0] * b[1] * b[2] * b[3] * b[-1], b[0] * b[1] * b[-1] * b[-2] * b[-3], b[-1] * b[-2] * b[-3] * b[-4] * b[-5]))


t = int(input())
for _ in range(t):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	m = l[0] * l[1] * l[2] * l[3] * l[4]
	if l[0] * l[1] * l[2] * l[3] * l[-1] > m:
		m = l[0] * l[1] * l[2] * l[3] * l[-1]
	if l[0] * l[1] * l[2] * l[-2] * l[-1] > m:
		m = l[0] * l[1] * l[2] * l[-2] * l[-1]
	if l[0] * l[1] * l[-3] * l[-2] * l[-1] > m:
		m = l[0] * l[1] * l[-3] * l[-2] * l[-1]
	if l[0] * l[-4] * l[-3] * l[-2] * l[-1] > m:
		m = l[0] * l[-4] * l[-3] * l[-2] * l[-1]
	if l[-5] * l[-4] * l[-3] * l[-2] * l[-1] > m:
		m = l[-5] * l[-4] * l[-3] * l[-2] * l[-1]
	print(m)


def Product(arr):
	product = 1
	for i in arr:
		product *= i
	return product

def Max_Product(n, arr):
	arr.sort()
	product_1 = Product(arr[n - 5:])
	product_2 = Product(arr[:2] + arr[n - 3:])
	product_3 = Product(arr[:4] + arr[n - 1:])
	return max(product_1, product_2, product_3)
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(Max_Product(n, arr))


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	res = []
	b = [[0, 1, 2, 3, 4], [0, 1, 2, 3, -1], [0, 1, 2, -2, -1], [0, 1, -3, -2, -1], [0, -4, -3, -2, -1], [-5, -4, -3, -2, -1]]
	for x in b:
		now = 1
		for y in x:
			now *= a[y]
		res.append(now)
	print(max(res))


def solve():
	n = int(input())
	arr = sorted([int(v) for v in input().split()])
	ans = -float('inf')
	for i in range(6):
		prod = 1
		comp = 5 - i
		for j in range(comp):
			prod *= arr[j]
		k = -1
		for j in range(i):
			prod *= arr[k]
			k -= 1
		ans = max(ans, prod)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


a = int(input())
for x in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	c.sort()
	j = max(c[0] * c[1] * c[2] * c[3] * c[4], c[0] * c[1] * c[2] * c[3] * c[-1], c[-1] * c[-2] * c[-3] * c[-4] * c[-5], c[0] * c[1] * c[-1] * c[-2] * c[-3])
	print(j)


t = int(input())

def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	ans = -10 ** 18
	ans = max(a[-5] * a[-4] * a[-3] * a[-2] * a[-1], ans)
	ans = max(a[-4] * a[-3] * a[-2] * a[-1] * a[0], ans)
	ans = max(a[-3] * a[-2] * a[-1] * a[0] * a[1], ans)
	ans = max(a[-2] * a[-1] * a[0] * a[1] * a[2], ans)
	ans = max(a[-1] * a[0] * a[1] * a[2] * a[3], ans)
	ans = max(a[0] * a[1] * a[2] * a[3] * a[4], ans)
	print(ans)
while t:
	t -= 1
	solve()


for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	p = []
	for k in range(1, 6):
		product = 1
		for i in range(1, k):
			product *= a[i - 1]
		for j in range(1, 7 - k):
			product *= a[n - j]
		p.append(product)
	print(max(p))


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	neg = a[:5]
	pos = a[-5:][::-1]
	maxi = -float('inf')
	for i in range(6):
		f = 1
		for j in range(i):
			f *= neg[j]
		for j in range(5 - i):
			f *= pos[j]
		maxi = max(maxi, f)
	print(maxi)


q = int(input())

def mult(x):
	i = 1
	for j in x:
		i *= j
	return i
while q:
	q -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	print(max(mult(a[-5:]), mult(a[:2] + a[-3:]), mult(a[:4] + a[-1:])))


import sys
input = sys.stdin.readline
from math import gcd
from operator import mul
from functools import reduce
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	best = -10 ** 99
	tmp = arr[-5:]
	tmp = reduce(lambda x, y: x * y, tmp, 1)
	best = max(best, tmp)
	tmp = arr[:2] + arr[-3:]
	tmp = reduce(lambda x, y: x * y, tmp, 1)
	best = max(best, tmp)
	tmp = arr[:4] + arr[-1:]
	tmp = reduce(lambda x, y: x * y, tmp, 1)
	best = max(best, tmp)
	print(best)


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	ans = 1
	if n == 5:
		for i in a:
			ans *= i
		print(ans)
	else:
		ans2 = a[-1] * a[0] * a[1] * a[2] * a[3]
		ans1 = a[-1] * a[-2] * a[-3] * a[1] * a[0]
		ans = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
		print(max(ans, ans1, ans2))


def solve():
	n = int(input())
	arr = [int(i) for i in input().strip().split()]
	pos = []
	neg = []
	for val in arr:
		if val >= 0:
			pos.append(val)
		else:
			neg.append(val)
	pos.sort(reverse=True)
	neg.sort(reverse=True)
	res = -1e+18
	for posv in range(0, 6):
		negv = 5 - posv
		if posv <= len(pos) and negv <= len(neg):
			cres = 1
			for j in range(0, posv):
				cres *= pos[j]
			if negv % 2 != 0:
				for j in range(0, negv):
					cres *= neg[j]
			else:
				for j in range(len(neg) - 1, len(neg) - 1 - negv, -1):
					cres *= neg[j]
			res = max(res, cres)
	print(res)
t = 1
t = int(input())
for i in range(0, t):
	solve()


for _ in range(int(input())):
	l = int(input())
	a = list(map(int, input().split()))
	a.sort()
	print(max(a[0] * a[1] * a[2] * a[3] * a[-1], a[-1] * a[-2] * a[-3] * a[-4] * a[-5], a[0] * a[1] * a[-2] * a[-3] * a[-1]))


for p in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	ans = 1
	if n == 5:
		for i in l:
			ans *= i
		print(ans)
	else:
		(a, b) = (0, n - 1)
		k = 0
		if l[-1] == 0:
			print(0)
		elif l[-1] < 0:
			for i in range(5):
				ans *= l[b - i]
			print(ans)
		elif l[-1] > 0:
			ans = l[-1]
			k = 1
			b -= 1
			while k != 5 and ans > 0:
				if l[a] * l[a + 1] > l[b] * l[b - 1]:
					k += 2
					ans *= l[a] * l[a + 1]
					a += 2
				else:
					ans *= l[b] * l[b - 1]
					b -= 2
					k += 2
			print(ans)


def solve(n, a):
	min1 = a.copy()
	max1 = a.copy()
	min2 = [0] * n
	max2 = [0] * n
	for m in range(2, 6):
		minv = min1[m - 2]
		maxv = max1[m - 2]
		for i in range(m - 1, n):
			ai = a[i]
			if ai > 0:
				min2[i] = minv * ai
				max2[i] = maxv * ai
			elif ai < 0:
				min2[i] = maxv * ai
				max2[i] = minv * ai
			else:
				min2[i] = 0
				max2[i] = 0
			minv = min(minv, min1[i])
			maxv = max(maxv, max1[i])
		(min1, max1, min2, max2) = (min2, max2, min1, max1)
	return max(max1[4:])

def main():
	t = int(input())
	anss = [0] * t
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		anss[i] = solve(n, a)
	for ans in anss:
		print(ans)
main()


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	tail = n - 1
	r1 = a[0] * a[1] * a[tail] * a[tail - 1] * a[tail - 2]
	r2 = a[0] * a[1] * a[2] * a[tail] * a[3]
	r3 = a[tail] * a[tail - 1] * a[tail - 2] * a[tail - 3] * a[tail - 4]
	print(max(r1, r2, r3))

def main():
	n = int(input())
	for i in range(n):
		solve()
main()


for _ in range(int(input())):
	(n, lst, cnt, ans) = (int(input()), sorted(map(int, input().split(' '))), 0, 1)
	for i in range(n - 1, -1, -1):
		ans *= lst[i]
		cnt += 1
		if cnt == 5:
			break
	(cnt, ans1) = (0, 1)
	for i in range(n):
		ans1 *= lst[i]
		cnt += 1
		if cnt == 4:
			break
	ans1 *= lst[-1]
	ans2 = lst[0] * lst[1] * lst[-1] * lst[-2] * lst[-3]
	print(max(ans, ans1, ans2))


from sys import stdin, stdout
t = int(stdin.readline())
while t:
	t -= 1
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	a.sort()
	result = float('-inf')
	for i in range(5):
		_5th = (n - 1 + i) % n
		_4th = (n - 2 + i) % n
		_3rd = (n - 3 + i) % n
		_2nd = (n - 4 + i) % n
		_1st = (n - 5 + i) % n
		result = max(result, a[_1st] * a[_2nd] * a[_3rd] * a[_4th] * a[_5th])
	print(result)


t = int(input())
for _ in range(t):
	num_items = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	if len(arr) == 5:
		ans = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	else:
		ans = max(arr[0] * arr[1] * arr[2] * arr[3] * arr[num_items - 1], arr[0] * arr[1] * arr[num_items - 3] * arr[num_items - 2] * arr[num_items - 1], arr[num_items - 1] * arr[num_items - 2] * arr[num_items - 3] * arr[num_items - 4] * arr[num_items - 5])
	print(ans)


def ret_mult(res, z_str):
	ret = 1
	for x in z_str:
		ret *= int(x)
	if ret > res:
		return ret
	return res
cases = input()
for _ in range(int(cases)):
	res = -999999999999999999999999999999
	len = int(input())
	x_str = input().strip().split(' ')
	for i in range(len):
		x_str[i] = int(x_str[i])
	x_str.sort()
	res = ret_mult(res, x_str[-5:])
	res = ret_mult(res, x_str[:4] + [x_str[-1]])
	res = ret_mult(res, x_str[:2] + x_str[-3:])
	print(res)


def product(a, i, j):
	n = len(a)
	x = a[0:i] + a[n - j:]
	k = 1
	for item in x:
		k = k * item
	return k
for item in [0] * int(input()):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	print(max(product(a, 0, 5), product(a, 2, 3), product(a, 4, 1)))


import sys
import math
input = sys.stdin.readline
from collections import deque
from queue import LifoQueue
from itertools import combinations
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	bc = []
	if n >= 10:
		for i in range(5):
			bc.append(a[i])
			bc.append(a[-1 - i])
	else:
		bc = a
	comb = combinations(bc, 5)
	ans = -10 ** 20
	for i in list(comb):
		ans = max(ans, i[0] * i[1] * i[2] * i[3] * i[4])
	print(ans)


import os
from io import BytesIO, IOBase
import sys

def main():
	for t in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		a.sort()
		ma = a[0] * a[1] * a[2] * a[3] * a[-1]
		ma = max(ma, a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
		ma = max(ma, a[-1] * a[-2] * a[-3] * a[0] * a[1])
		print(ma)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a1 = l[-5] * l[-4] * l[-1] * l[-2] * l[-3]
	a2 = l[0] * l[1] * l[-1] * l[-2] * l[-3]
	a3 = l[0] * l[1] * l[2] * l[3] * l[-1]
	print(max(a1, a2, a3))


import os
from sys import stdin, stdout

def solve(tc):
	n = int(stdin.readline().strip())
	seq = list(map(int, stdin.readline().split()))
	zero = 0
	minus = []
	plus = []
	for i in range(n):
		if seq[i] > 0:
			plus.append(seq[i])
		elif seq[i] < 0:
			minus.append(seq[i])
		else:
			zero += 1
	plus = sorted(plus)
	minus = sorted(minus)
	ans = -int(1e+18)
	if len(plus) >= 5:
		val = 1
		for i in range(-1, -6, -1):
			val *= plus[i]
		ans = max(ans, val)
	if len(plus) >= 3 and len(minus) >= 2:
		val = 1
		for i in range(2):
			val *= minus[i]
		for i in range(-1, -4, -1):
			val *= plus[i]
		ans = max(ans, val)
	if len(plus) >= 1 and len(minus) >= 4:
		val = 1
		for i in range(4):
			val *= minus[i]
		val *= plus[-1]
		ans = max(ans, val)
	if zero > 0:
		ans = max(ans, 0)
	seq = sorted(seq, key=lambda x: -x if x < 0 else x)
	val = 1
	for i in range(5):
		val *= seq[i]
	ans = max(ans, val)
	print(ans)
tcs = 1
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


def fun(A):
	k = 5
	A.sort()
	prod = 1
	if A[-1] == 0:
		return 0
	elif A[-1] < 0:
		for i in range(-1, -1 - k, -1):
			prod = prod * A[i]
		return prod
	i = 0
	j = len(A) - 1
	prod = prod * A[j]
	j -= 1
	k -= 1
	k = k >> 1
	for idx in range(k):
		left = A[i] * A[i + 1]
		right = A[j] * A[j - 1]
		if left > right:
			prod = prod * left
			i += 2
		else:
			prod = prod * right
			j -= 2
	return prod
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(fun(arr))


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort(reverse=True)
	a = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	b = arr[0] * arr[1] * arr[2] * arr[n - 1] * arr[n - 2]
	c = arr[0] * arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4]
	print(max(a, b, c))


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	P = [A[i] for i in range(N) if A[i] >= 0]
	P.sort(reverse=True)
	Q = [A[i] for i in range(N) if A[i] < 0]
	Q.sort()
	ans = -float('inf')
	for i in range(6):
		if i <= len(P) and 5 - i <= len(Q):
			s = 1
			for j in range(i):
				s *= P[j]
			for k in range(5 - i):
				if (5 - i) % 2 == 1:
					s *= Q[-(k + 1)]
				else:
					s *= Q[k]
			ans = max(ans, s)
	print(ans)


t = int(input())
for q in range(0, t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a, key=abs, reverse=True)
	ans = a[0] * a[1] * a[2] * a[3] * a[4]
	count = 0
	for i in range(0, n):
		if a[i] >= 0:
			count += 1
	if count == 0:
		print(a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5])
	elif ans >= 0:
		print(ans)
	else:
		ans0 = a[1] * a[2] * a[3] * a[4]
		ans1 = a[0] * a[2] * a[3] * a[4]
		ans2 = a[0] * a[1] * a[3] * a[4]
		ans3 = a[0] * a[1] * a[2] * a[4]
		ans4 = a[0] * a[1] * a[2] * a[3]
		for i in range(5, n):
			c1 = ans0 * a[i]
			c2 = ans1 * a[i]
			c3 = ans2 * a[i]
			c4 = ans3 * a[i]
			c5 = ans4 * a[i]
			ans = max(ans, c1, c2, c3, c4, c5)
		print(ans)


tests = int(input())
for test in range(tests):
	n = input()
	l = sorted([int(x) for x in input().split(' ')])
	x = l[-5] * l[-4] * l[-3] * l[-2] * l[-1]
	y = l[0] * l[1] * l[-3] * l[-2] * l[-1]
	z = l[0] * l[1] * l[2] * l[3] * l[-1]
	print(max([x, y, z]))


for _ in ' ' * int(input()):
	input()
	a = sorted(list(map(int, input().split())))
	print(max(a[0] * a[1] * a[2] * a[3] * a[-1], a[-1] * a[-2] * a[-3] * a[-4] * a[-5], a[0] * a[1] * a[-2] * a[-3] * a[-1]))


def maximise_product():
	n = int(input())
	arr = [int(j) for j in input().split()]
	arr.sort()
	left_product_1 = arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3]
	left_product_2 = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	res = 1
	for i in range(n - 1, n - 6, -1):
		res *= arr[i]
	if res < left_product_1:
		res = left_product_1
	if res < left_product_2:
		res = left_product_2
	print(res)
t = int(input())
for i in range(0, t):
	maximise_product()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	x = int(input())
	(*li,) = map(int, input().split())
	li.sort()
	a = li[-1] * li[-2] * li[-3] * li[-4] * li[-5]
	b = li[-1] * li[-2] * li[-3] * li[0] * li[1]
	c = li[-1] * li[-2] * li[-3] * li[0] * li[-4]
	d = li[-1] * li[-2] * li[2] * li[0] * li[1]
	e = li[-1] * li[2] * li[3] * li[0] * li[1]
	f = li[4] * li[2] * li[3] * li[0] * li[1]
	print(max(a, b, c, d, e, f))


def main_function():
	tests = range(int(input()))
	ans = []
	for test in tests:
		n = int(input())
		a = sorted([int(i) for i in input().split(' ')])
		if max(a) == 0:
			print(0)
		elif max(a) < 0:
			print(a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
		elif len(a) == 5:
			print(a[0] * a[1] * a[2] * a[3] * a[4])
		elif min(a) >= 0:
			print(a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
		else:
			first_element = max(a)
			a.pop()
			if a[0] * a[1] > a[-1] * a[-2]:
				second_and_third = a[0] * a[1]
				a.pop(0)
				a.pop(0)
			else:
				second_and_third = a[-1] * a[-2]
				a.pop()
				a.pop()
			if a[0] * a[1] > a[-1] * a[-2]:
				fourth_and_fifth = a[0] * a[1]
				a.pop(0)
				a.pop(0)
			else:
				fourth_and_fifth = a[-1] * a[-2]
				a.pop()
				a.pop()
			print(first_element * second_and_third * fourth_and_fifth)
main_function()


def main():
	n = int(input())
	k = 5
	al = list(map(int, input().split()))
	al_abs = []
	al_nl = []
	for a in al:
		if a > 0:
			sig = 1
		elif a < 0:
			sig = -1
			al_nl.append(a)
		else:
			sig = 0
		al_abs.append((abs(a), sig))
	if n == k:
		ans = 1
		for i in range(k):
			a = al[i]
			ans *= a
		print(ans)
		return
	al_abs.sort(reverse=True)
	n_cnt = 0
	last_p = -1
	last_n = -1
	for i in range(k):
		(a, sig) = al_abs[i]
		if sig == -1:
			n_cnt += 1
			last_n = i
		elif sig == 1:
			last_p = i
	ans = 1
	if n_cnt % 2 == 0:
		for i in range(k):
			(a, sig) = al_abs[i]
			ans *= a
		print(ans)
		return
	next_p = -1
	next_n = -1
	for i in range(k, n):
		(a, sig) = al_abs[i]
		if sig == 1 and next_p == -1:
			next_p = i
		elif sig == -1 and next_n == -1:
			next_n = i
		if next_n != -1 and next_p != -1:
			break
	comp_np = 0
	if next_p != -1:
		last_n_val = al_abs[last_n][0]
		next_p_val = al_abs[next_p][0]
		comp_np = next_p_val * 1.0 / last_n_val
	comp_pn = 0
	if next_n != -1 and last_p != -1:
		last_p_val = al_abs[last_p][0]
		next_n_val = al_abs[next_n][0]
		comp_pn = next_n_val * 1.0 / last_p_val
	if comp_np == 0 and comp_pn > 0:
		np_or_pn = False
	elif comp_pn == 0 and comp_np > 0:
		np_or_pn = True
	elif comp_np > 0 and comp_pn > 0:
		if next_p_val * last_p_val > next_n_val * last_n_val:
			np_or_pn = True
		else:
			np_or_pn = False
	elif comp_np == 0 and comp_pn == 0:
		if 0 in al:
			print(0)
			return
		else:
			al_nl.sort(reverse=True)
			for i in range(k):
				a = al_nl[i]
				ans *= a
			print(ans)
			return
	for i in range(k):
		if np_or_pn and i == last_n:
			continue
		if not np_or_pn and i == last_p:
			continue
		(a, sig) = al_abs[i]
		ans *= a
	if np_or_pn:
		ans *= next_p_val
	else:
		ans *= next_n_val
	print(ans)
for _ in range(int(input())):
	main()


def ans(n, a):
	ans = -float('inf')
	(neg, pos) = ([], [])
	(lp, ln) = (0, 0)
	for i in range(n):
		if a[i] >= 0:
			pos.append(a[i])
			lp += 1
		else:
			neg.append(a[i])
			ln += 1
	neg.sort()
	pos.sort(reverse=True)
	if ln == 0:
		return pos[0] * pos[1] * pos[2] * pos[3] * pos[4]
	if lp == 0:
		return neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5]
	if lp >= 1 and ln >= 4:
		ans = max(ans, neg[0] * neg[1] * neg[2] * neg[3] * pos[0])
	if lp >= 2 and ln >= 3:
		ans = max(ans, pos[0] * pos[1] * neg[-1] * neg[-2] * neg[-3])
	if lp >= 3 and ln >= 2:
		ans = max(ans, neg[0] * neg[1] * pos[0] * pos[1] * pos[2])
	if lp >= 4 and ln >= 1:
		ans = max(ans, pos[0] * pos[1] * pos[2] * pos[3] * neg[-1])
	if lp >= 5:
		ans = max(ans, pos[0] * pos[1] * pos[2] * pos[3] * pos[4])
	if ln >= 5:
		ans = max(ans, neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5])
	return ans
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split(' ')))
	out = ans(n, a)
	print(out)
	t -= 1


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		A = [int(x) for x in input().split()]
		ans = 1
		if n == 5:
			for ele in A:
				ans *= ele
			print(ans)
			continue
		(count_neg, count_pos, count_zer) = (0, 0, 0)
		pos = []
		neg = []
		for ele in A:
			if ele < 0:
				count_neg += 1
				neg.append(ele)
			elif ele > 0:
				count_pos += 1
				pos.append(ele)
			else:
				count_zer += 1
		if n - count_zer < 5:
			print(0)
			continue
		elif n - count_zer == 5:
			ans = 1
			for ele in pos:
				ans *= ele
			for ele in neg:
				ans *= ele
			res = ans
			if count_zer > 0:
				if res < 0:
					res = 0
			print(res)
			continue
		pos.sort()
		neg.sort()
		(a, b, c, d, e, f) = [-243000000000000001 for i in range(6)]
		if count_pos >= 5:
			ans = 1
			for ele in pos[-5:]:
				ans *= ele
			if a < ans:
				a = ans
		if count_neg >= 2 and count_pos >= 3:
			ans = 1
			for ele in pos[-3:]:
				ans *= ele
			for ele in neg[:2]:
				ans *= ele
			if b < ans:
				b = ans
		if count_neg >= 4 and count_pos >= 1:
			ans = 1
			for ele in neg[:4]:
				ans *= ele
			ans *= pos[-1]
			if c < ans:
				c = ans
		if count_neg >= 1 and count_pos >= 4:
			ans = 1
			ans *= neg[-1]
			for ele in pos[:4]:
				ans *= ele
			if d < ans:
				d = ans
		if count_neg >= 3 and count_pos >= 2:
			ans = 1
			for ele in neg[-3:]:
				ans *= ele
			for ele in pos[:2]:
				ans *= ele
			if e < ans:
				e = ans
		if count_neg >= 5:
			ans = 1
			for ele in neg[-5:]:
				ans *= ele
			if f < ans:
				f = ans
		res = max([a, b, c, d, e, f])
		if count_zer > 0:
			if res < 0:
				res = 0
		print(res)
main()


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = -1
	for r in range(6):
		l = 5 - r
		currans = 1
		for i in range(l):
			currans *= a[i]
		for i in range(n - 1, n - 1 - r, -1):
			currans *= a[i]
		if ans == -1:
			ans = currans
		else:
			ans = max(ans, currans)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	m1 = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	m2 = arr[0] * arr[1] * arr[2] * arr[n - 1] * arr[3]
	m3 = arr[0] * arr[1] * arr[n - 1] * arr[n - 2] * arr[2]
	m4 = arr[0] * arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[1]
	m5 = arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[0]
	m6 = arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5]
	print(max(m1, m2, m3, m4, m5, m6))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(pos, neg) = ([], [])
	for x in l:
		if x >= 0:
			pos.append(x)
		else:
			neg.append(abs(x))
	pos.sort(reverse=True)
	neg.sort(reverse=True)
	ans = -1e+18
	if len(pos) == 0 or len(neg) >= 5:
		ans = max(ans, -1 * neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5])
	if len(neg) == 0 or len(pos) >= 5:
		ans = max(ans, pos[0] * pos[1] * pos[2] * pos[3] * pos[4])
	if len(pos) >= 1:
		if 3 < len(neg):
			ans = max(ans, pos[0] * neg[0] * neg[1] * neg[2] * neg[3])
	if len(pos) >= 2:
		if 2 < len(neg):
			ans = max(ans, -1 * pos[-1] * pos[-2] * neg[-1] * neg[-2] * neg[-3])
	if len(pos) >= 3:
		if 1 < len(neg):
			ans = max(ans, pos[0] * pos[1] * pos[2] * neg[0] * neg[1])
	if len(pos) >= 4:
		if len(neg) > 0:
			ans = max(ans, -1 * pos[-1] * pos[-2] * pos[-3] * pos[-4] * neg[-1])
	print(ans)


import itertools
import functools
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pos_a = list(filter(lambda x: x >= 0, a))
	neg_a = list(filter(lambda x: x < 0, a))
	pos_a.sort()
	neg_a.sort(reverse=True)
	if not len(pos_a):
		print(functools.reduce(lambda a, b: a * b, neg_a[:5]))
		continue
	max_pos = pos_a[-5:]
	max_neg = neg_a[-5:]
	max_prod = float('-inf')
	for comb in itertools.combinations(max_pos + max_neg, 5):
		max_prod = max(max_prod, functools.reduce(lambda a, b: a * b, comb))
	print(max_prod)


import sys
input = sys.stdin.buffer.readline
INF = 10 ** 19
Q = int(input())
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	Minus = []
	Plus = []
	for a in A:
		if a > 0:
			Plus.append(a)
		elif a < 0:
			Minus.append(-a)
	Plus.sort(reverse=True)
	Minus.sort(reverse=True)
	ans = -INF
	if len(Minus) >= 5:
		ans = max(ans, -Minus[-1] * Minus[-2] * Minus[-3] * Minus[-4] * Minus[-5])
	if len(Minus) >= 3 and len(Plus) >= 2:
		ans = max(ans, -Minus[-1] * Minus[-2] * Minus[-3] * Plus[-1] * Plus[-2])
	if len(Minus) >= 1 and len(Plus) >= 4:
		ans = max(ans, -Minus[-1] * Plus[-1] * Plus[-2] * Plus[-3] * Plus[-4])
	if len(Plus) >= 5:
		ans = max(ans, Plus[0] * Plus[1] * Plus[2] * Plus[3] * Plus[4])
	if len(Plus) >= 3 and len(Minus) >= 2:
		ans = max(ans, Plus[0] * Plus[1] * Plus[2] * Minus[0] * Minus[1])
	if len(Plus) >= 1 and len(Minus) >= 4:
		ans = max(ans, Plus[0] * Minus[0] * Minus[1] * Minus[2] * Minus[3])
	if 0 in A:
		ans = max(ans, 0)
	print(ans)


from heapq import heapify, heappop, heappush, nlargest, nsmallest
import operator as op
from functools import reduce
prod = lambda x: reduce(op.mul, x)

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		a.sort()
		(pos, neg) = (list(filter(lambda x: x >= 0, a)), list(filter(lambda x: x < 0, a)))
		l = []
		if len(pos) >= 5:
			l.append(pos[-5:])
		if len(pos) >= 3 and len(neg) >= 2:
			l.append(pos[-3:] + neg[:2])
		if len(pos) >= 1 and len(neg) >= 4:
			l.append(pos[-1:] + neg[:4])
		if len(neg) >= 5:
			l.append(neg[-5:])
		if not l and len(a) == 5:
			l.append(a)
		print(prod(max(l, key=lambda x: prod(x))))
main()


def m(l, n):
	m1 = l[0] * l[1] * l[n - 3] * l[n - 2] * l[n - 1]
	m2 = l[0] * l[1] * l[2] * l[3] * l[n - 1]
	m3 = l[n - 5] * l[n - 4] * l[n - 3] * l[n - 2] * l[n - 1]
	return max(m1, m2, m3)
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 5:
		print(l[0] * l[1] * l[2] * l[3] * l[4])
	else:
		l = sorted(l)
		ans = m(l, n)
		print(ans)


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	A.sort()
	ans = -10 ** 27
	for j in range(5):
		B = A[:j] + A[j - 5:]
		c = 1
		for b in B:
			c *= b
		ans = max(ans, c)
	B = A[:5]
	c = 1
	for b in B:
		c *= b
	ans = max(ans, c)
	print(ans)


w = int(input())
for z in range(w):
	a = int(input())
	lista = list(map(int, input().split()))
	lista.sort()
	listmin = []
	listmax = []
	counter = 0
	b = 1
	for g in range(5):
		if lista[-g - 1] > -1:
			listmax.append(lista[-g - 1])
			counter += 1
		else:
			break
	if len(listmax) == 0:
		for i in range(5):
			listmin.append(lista[-1 - i])
	elif a - counter > 4:
		for i in range(5):
			listmin.append(lista[i])
	else:
		for i in range(a - counter):
			if lista[i] < 0:
				listmin.append(lista[i])
			else:
				break
	listmax.sort()
	c = len(listmin)
	if c % 2 != 0:
		c -= 1
	y = len(listmax)
	if y % 2 == 0:
		y -= 1
	if a == 5:
		for l in range(5):
			b *= lista[l]
	elif y == -1:
		for l in range(5):
			b *= listmin[-l - 1]
	elif y != 5:
		t = 5 - y
		if len(listmax) - y == 1:
			listmax.remove(listmax[0])
		for k in range(t // 2):
			listmax.append(listmin[0])
			listmax.append(listmin[1])
			listmin.remove(listmin[0])
			listmin.remove(listmin[0])
		if y == 3 and len(listmin) > 1:
			if listmin[0] * listmin[1] > listmax[0] * listmax[1]:
				listmax[0] = listmin[0]
				listmax[1] = listmin[1]
		for l in range(5):
			b *= listmax[l]
	else:
		for q in range(c // 2):
			if listmin[2 * q] * listmin[2 * q + 1] > listmax[2 * q] * listmax[2 * q + 1]:
				listmax[2 * q] = listmin[2 * q]
				listmax[2 * q + 1] = listmin[2 * q + 1]
		for l in range(5):
			b *= listmax[l]
	print(b)


import sys
cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	la = n
	if n > 9:
		a = a[:5] + a[-5:]
		la = 10
	mv = (-3 * 10 ** 3) ** 5
	for i in range(la - 4):
		for j in range(i + 1, la - 3):
			for k in range(j + 1, la - 2):
				for l in range(k + 1, la - 1):
					for m in range(l + 1, la):
						mv = max(a[i] * a[j] * a[k] * a[l] * a[m], mv)
	print(mv)


import math
from collections import Counter
from functools import lru_cache
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	(positive, negative) = ([], [])
	for i in arr:
		if i < 0:
			negative.append(abs(i))
		else:
			positive.append(i)
	ans = 1
	positive.sort(reverse=True)
	negative.sort(reverse=True)
	count = 0
	for i in range(min(5, len(positive))):
		ans *= positive[i]
		count += 1
	for i in range(5 - count):
		ans *= -negative[len(negative) - 1 - i]
	temp2 = 1
	count = 0
	if len(negative) >= 2:
		for i in range(min(3, len(positive))):
			temp2 *= positive[i]
			count += 1
		for i in range(5 - count):
			temp2 *= -negative[i]
		ans = max(ans, temp2)
	if len(negative) >= 4:
		temp2 = 1
		count = 0
		for i in range(min(1, len(positive))):
			temp2 *= positive[i]
			count += 1
		for i in range(5 - count):
			temp2 *= -negative[i]
		ans = max(ans, temp2)
	print(ans)


from functools import lru_cache
import sys
import math
mod = 10 ** 9 + 7
inf = float('inf')

def arrInt():
	return list(map(int, input().split()))

def solve(n, arr):
	arr.sort()
	ans = -inf
	f = arr[:5]
	l = arr[-5:][::-1]
	for i in range(6):
		x = 1
		for j in range(5 - i):
			x *= f[j]
		for j in range(i):
			x *= l[j]
		ans = max(ans, x)
	print(ans)
if 1 == 2:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	arr = arrInt()
	solve(n, arr)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	zero = 0
	for i in a:
		if not i:
			zero += 1
	if n - zero < 5:
		print(0)
		continue
	neg = []
	pos = []
	abso = []
	for i in a:
		abso += [abs(i)]
		if i < 0:
			neg += [-i]
		if i > 0:
			pos += [i]
	neg = sorted(neg, reverse=True)
	pos = sorted(pos, reverse=True)
	ans = -10 ** 24
	if len(pos) >= 5:
		ans = max(ans, pos[0] * pos[1] * pos[2] * pos[3] * pos[4])
	if len(neg) >= 2 and len(pos) >= 3:
		ans = max(ans, pos[0] * pos[1] * pos[2] * neg[0] * neg[1])
	if len(neg) >= 4 and len(pos) >= 1:
		ans = max(ans, pos[0] * neg[0] * neg[1] * neg[2] * neg[3])
	if ans > -10 ** 24:
		print(ans)
		continue
	if zero:
		print(0)
		continue
	abso = sorted(abso)
	print(-abso[0] * abso[1] * abso[2] * abso[3] * abso[4])


def solve(lst):
	lst = sorted(lst)
	neg = 0
	negs = []
	ans = 1
	pos = []
	for i in range(len(lst)):
		if lst[i] < 0:
			neg += 1
			negs.append(lst[i])
		else:
			pos.append(lst[i])
	if len(pos) == 0:
		if len(negs) > 5:
			negs = negs[::-1][0:5]
		for i in negs:
			ans *= i
		return ans
	pos = pos[::-1]
	if len(negs) > 5:
		negs = negs[0:5]
	if len(pos) > 5:
		pos = pos[0:5]
	maxed = -90210120921092190219090129
	end = len(pos)
	minus = 5 - end
	for x in range(len(pos)):
		if end + minus < 5 or minus > len(negs):
			break
		p = 1
		for i in pos[0:end]:
			p *= i
		kl = 0
		for i in negs[0:minus]:
			p *= i
		maxed = max(p, maxed)
		minus += 1
		end -= 1
	return maxed
k = int(input())
for i in range(k):
	m = int(input())
	lst = list(map(int, input().split()))
	print(solve(lst))


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	pro = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	pro = max(pro, arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5])
	pro = max(pro, arr[-1] * arr[-2] * arr[-3] * arr[0] * arr[1])
	pro = max(pro, arr[-1] * arr[0] * arr[1] * arr[2] * arr[3])
	print(pro)
	t -= 1


t = int(int(input()))
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = a[0] * a[1] * a[2] * a[3] * a[4]
	c = a[0] * a[1] * a[2] * a[3] * a[-1]
	d = a[0] * a[1] * a[2] * a[-2] * a[-1]
	e = a[0] * a[1] * a[-3] * a[-2] * a[-1]
	f = a[0] * a[-4] * a[-3] * a[-2] * a[-1]
	g = a[-5] * a[-4] * a[-3] * a[-2] * a[-1]
	print(max(b, c, d, e, f, g))


cases = int(input())
for _ in range(cases):
	n = int(input())
	ds = list(map(int, input().split()))
	big = [ds[0]]
	sma = [ds[0]]
	for i in range(1, n):
		v = ds[i]
		big.append(max(big[-1], v))
		sma.append(min(sma[-1], v))
	for c in range(1, 5):
		tbig = []
		tsma = []
		for i in range(c, n):
			v = ds[i]
			left = big[i - c] * v
			right = sma[i - c] * v
			tbig.append(max(left, right))
			tsma.append(min(left, right))
			if len(tbig) > 1:
				tbig[-1] = max(tbig[-1], tbig[-2])
				tsma[-1] = min(tsma[-1], tsma[-2])
		big = tbig
		sma = tsma
	print(max(big))


n = int(input())

def multuple(nums):
	res = 1
	for i in nums:
		res *= i
	return res
for i in range(n):
	input()
	nums = list(map(int, input().split()))
	nums.sort()
	print(max(multuple(nums[:4]) * nums[-1], multuple(nums[:2]) * multuple(nums[-1:-4:-1]), multuple(nums[-1:-6:-1])))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	pos = 0
	neg = 0
	zer = 0
	ans = 0
	for i in range(n):
		if l[i] < 0:
			neg += 1
		if l[i] > 0:
			pos += 1
		else:
			zer += 1
	if n == 5:
		print(l[0] * l[1] * l[2] * l[3] * l[4])
		continue
	elif pos + neg < 5:
		print(0)
		continue
	elif pos == 0:
		print(l[-1] * l[-2] * l[-3] * l[-4] * l[-5])
		continue
	else:
		ans = max(l[0] * l[1] * l[2] * l[3] * l[-1], l[0] * l[1] * l[-3] * l[-2] * l[-1], l[-5] * l[-4] * l[-3] * l[-2] * l[-1])
		print(ans)
		continue


for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	a1 = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	a2 = arr[-1] * arr[-2] * arr[-3] * arr[0] * arr[1]
	a3 = arr[-1] * arr[3] * arr[0] * arr[1] * arr[2]
	print(max(a1, a2, a3))


def prod(arr):
	s = 1
	for v in arr:
		s *= v
	return s
for _ in range(int(input())):
	n = int(input())
	(*arr,) = map(int, input().split())
	arr.sort()
	print(max(prod(arr[-5:]), prod(arr[:2] + arr[-3:]), prod(arr[:4] + arr[-1:])))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(neg, pos, zero) = ([], [], [])
	for i in sorted(a):
		if i < 0:
			neg.append(i)
		elif i > 0:
			pos.append(i)
		elif i == 0:
			zero.append(i)
	neg = neg[::-1]
	(pl, nl) = (len(pos), len(neg))
	ans = float('-inf')
	for i in range(min(nl + 1, 6)):
		t = None
		no = 0
		if i % 2 == 0:
			for j in range(nl - 1, nl - i - 1, -1):
				if t == None:
					t = neg[j]
				else:
					t *= neg[j]
				no += 1
			for j in range(pl - 1, pl - min(5 - no, pl) - 1, -1):
				if t == None:
					t = pos[j]
				else:
					t *= pos[j]
				no += 1
		else:
			for j in range(min(i, nl)):
				if t == None:
					t = neg[j]
				else:
					t *= neg[j]
				no += 1
			for j in range(min(5 - no, pl)):
				if t == None:
					t = pos[j]
				else:
					t *= pos[j]
				no += 1
		if no == 5:
			if ans < 0 and zero:
				ans = 0
			ans = max(ans, t)
		elif len(zero) + no >= 5:
			ans = max(ans, 0)
	print(ans)


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		n = iin()
		a = ain()
		a.sort()
		cn = 0
		z = 0
		cp = 0
		for i in a:
			if i < 0:
				cn += 1
			elif i == 0:
				z = 1
			else:
				cp += 1
		ans = max(a[0] * a[1] * a[-1] * a[-2] * a[-3], a[0] * a[1] * a[2] * a[3] * a[-1], a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import *
from collections import Counter
input = lambda : stdin.readline()
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
for _ in range(int(input())):
	n = int(input())
	arr = sorted(int_arr())
	frst = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	scnd = arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3]
	third = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	print(max((frst, scnd, third)))


from collections import *
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 1
	ans2 = 1
	ans3 = 1
	(ans4, ans5, ans6) = (1, 1, 1)
	ans *= l[0] * l[1] * l[2] * l[3] * l[4]
	ans2 *= l[0] * l[1] * l[2] * l[3] * l[-1]
	ans3 *= l[0] * l[1] * l[2] * l[-2] * l[-1]
	ans4 *= l[0] * l[1] * l[-3] * l[-2] * l[-1]
	ans5 *= l[0] * l[-4] * l[-3] * l[-2] * l[-1]
	ans6 *= l[-5] * l[-4] * l[-3] * l[-2] * l[-1]
	print(max(ans, ans2, ans3, ans4, ans5, ans6))


from functools import reduce
import operator

def prod(iterable):
	return reduce(operator.mul, iterable, 1)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a = arr[:4] + arr[-1:]
	b = arr[:2] + arr[-3:]
	c = arr[-5:]
	print(max(prod(a), prod(b), prod(c)))


def prod(list):
	p = 1
	for i in list:
		p *= i
	return p
T = int(input())
for test in range(T):
	n = int(input())
	a = [int(i) for i in input().split()]
	if n == 5:
		print(prod(a))
	else:
		pos = []
		neg = []
		for i in range(n):
			if a[i] < 0:
				neg.append(-a[i])
			else:
				pos.append(a[i])
		pos.sort()
		neg.sort()
		ans = []
		for i in range(6):
			j = 5 - i
			if len(pos) >= i and len(neg) >= j:
				if j % 2 == 1:
					ans.append(-prod(pos[:i]) * prod(neg[:j]))
				elif i == 0:
					ans.append(prod(neg[-j:]))
				elif j == 0:
					ans.append(prod(pos[-i:]))
				else:
					ans.append(prod(pos[-i:]) * prod(neg[-j:]))
		print(max(ans))


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	neg = 0
	zero = 0
	for e in l:
		if e < 0:
			neg += 1
		elif e == 0:
			zero += 1
		else:
			break
	if zero == n - 4:
		return 0
	t = [l[i] for i in range(5)] + [l[i] for i in range(n - 5, n)]
	if neg >= 4:
		res1 = t[0] * t[1] * t[2] * t[3] * t[9]
		res2 = t[0] * t[1] * t[7] * t[8] * t[9]
		res3 = t[5] * t[6] * t[7] * t[8] * t[9]
		return max(res1, res2, res3)
	if neg >= 2:
		res2 = t[0] * t[1] * t[7] * t[8] * t[9]
		res3 = t[5] * t[6] * t[7] * t[8] * t[9]
		return max(res2, res3)
	return t[5] * t[6] * t[7] * t[8] * t[9]
for __ in range(int(input())):
	print(solve())


def mul(arr):
	res = 1
	for e in arr:
		res *= e
	return res
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	res = []
	positive = sorted([e for e in a if e >= 0], reverse=True)
	negative = sorted([e for e in a if e < 0], reverse=False)
	for e in positive:
		if e == 0:
			res.append(0)
			break
	if len(positive) >= 5:
		res.append(mul(positive[:5]))
	if len(negative) >= 5:
		res.append(mul(negative[len(negative) - 5:]))
	for i in range(1, 5):
		if len(negative) >= 5 - i and len(positive) >= i:
			if (5 - i) % 2 == 0:
				res.append(mul(negative[:5 - i]) * mul(positive[:i]))
			else:
				res.append(mul(negative[len(negative) - 5 + i:]) * mul(positive[len(positive) - i:]))
	print(max(res))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	pos = []
	neg = []
	for i in arr:
		if i >= 0:
			pos += [i]
		elif i < 0:
			neg += [i]
	pos.sort(reverse=True)
	neg.sort()
	ans = -99999999999
	for i in range(0, min(len(neg) + 1, 5), 2):
		prod = 1
		for j in range(i):
			prod *= neg[j]
		for k in range(min(5 - i, len(pos))):
			prod *= pos[k]
		if i + len(pos) >= 5:
			ans = max(ans, prod)
	arr.sort(reverse=True)
	if ans == -99999999999:
		prod = 1
		for i in range(5):
			prod *= arr[i]
		ans = prod
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	s = a[0] * a[1] * a[2] * a[3] * a[-1]
	m = a[0] * a[1] * a[-3] * a[-2] * a[-1]
	l = a[-5] * a[-4] * a[-3] * a[-2] * a[-1]
	if s > m and s > l:
		print(s)
	elif m > l:
		print(m)
	else:
		print(l)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	p1 = a[0] * a[1] * a[2] * a[3] * a[4]
	p2 = a[0] * a[1] * a[2] * a[3] * a[n - 1]
	p3 = a[0] * a[1] * a[2] * a[n - 1] * a[n - 2]
	p4 = a[0] * a[1] * a[n - 1] * a[n - 2] * a[n - 3]
	p5 = a[0] * a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4]
	p6 = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5]
	print(max(p1, p2, p3, p4, p5, p6))


rw = int(input())
for wewq in range(rw):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	f = []
	b = a[0:5]
	c = a[n - 5:n]
	c.reverse()
	for i in range(5):
		q = 1
		for j in range(i):
			q = q * b[j]
		for j in range(5 - i):
			q = q * c[j]
		f.append(q)
	print(max(f))


def case_0(n, a):
	p = 1
	for i in range(1, 6):
		p *= a[-i]
	return p

def case_2(n, a):
	p = 1
	for i in range(1, 4):
		p *= a[-i]
	p *= a[0]
	p *= a[1]
	return p

def case_4(n, a):
	p = a[-1]
	for i in range(4):
		p *= a[i]
	return p

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		a.sort()
		c0 = case_0(n, a)
		c2 = case_2(n, a)
		c4 = case_4(n, a)
		print(max([c0, c2, c4]))
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = 1
	for i in range(n - 5, n):
		c *= l[i]
	ans = c
	kk = 0
	c = l[-1]
	for i in range(4):
		if l[i] < 0:
			kk += 1
			c *= l[i]
	if kk == 4:
		ans = max(ans, c)
	c = l[-1]
	kk = 0
	for i in range(2):
		if l[i] < 0:
			c *= l[i]
			c *= l[n - i - 2]
			kk += 1
	if kk == 2:
		ans = max(ans, c)
	print(ans)


from collections import Counter
t = int(input())
for i in range(t):
	n = input()
	nums = list(map(int, input().split()))
	a = [i for i in nums if i > 0]
	b = [-i for i in nums if i < 0]
	a.sort(reverse=True)
	b.sort(reverse=True)
	zero = 0 in nums
	if len(a) + len(b) < 5:
		print(0)
		continue
	ans = -1e+20
	for left in range(6):
		try:
			right = 5 - left
			cur = 1
			for j in range(left):
				cur *= a[j]
			for j in range(right):
				cur *= -b[j]
			if ans < cur:
				ans = cur
		except:
			pass
	for left in range(6):
		try:
			right = 5 - left
			cur = 1
			for j in range(left):
				cur *= a[-j - 1]
			for j in range(right):
				cur *= -b[-j - 1]
			if ans < cur:
				ans = cur
		except:
			pass
	if ans < 0 and zero:
		print(0)
	else:
		print(ans)


def mex(a):
	a_s = list(set(a))
	a_s.sort()
	for i in range(len(a_s)):
		if i != a_s[i]:
			return i
	return len(a_s)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	m = 1
	for i in arr[:5]:
		m *= i
	ret = 1
	for i in range(6):
		for j in arr[:i]:
			ret *= j
		for j in arr[n - 5 + i:]:
			ret *= j
		if ret > m:
			m = ret
		ret = 1
	print(m)


import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda : list(map(int, input().split()))

def main():
	n = I()
	arr = ARR()
	arr.sort()
	(l, r) = (0, n - 1)
	ans = 1
	if arr[r] <= 0:
		for _ in range(5):
			ans *= arr[r]
			r -= 1
		print(ans)
		return
	ans = arr[r]
	r -= 1
	for _ in range(2):
		a1 = arr[l] * arr[l + 1]
		a2 = arr[r] * arr[r - 1]
		if a1 > a2:
			l += 2
			ans *= a1
		else:
			r -= 2
			ans *= a2
	print(ans)
tc = I()
for _ in range(tc):
	main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pos = []
	neg = []
	zero = 0
	for j in range(n):
		if a[j] > 0:
			pos.append(a[j])
		elif a[j] < 0:
			neg.append(-a[j])
		else:
			zero += 1
	pos.sort()
	neg.sort()
	if len(a) == 5 and zero == 0 and (len(pos) in [0, 2, 4]):
		ans = 1
		for j in range(5):
			ans *= a[j]
	elif not pos and (not zero):
		ans = -1
		for j in range(5):
			ans *= neg[j]
	else:
		(posone, posthree, posfive) = (0, 0, 0)
		if len(pos) >= 5:
			posfive = 1
			for j in range(1, 6):
				posfive *= pos[-j]
		if len(pos) >= 3 and len(neg) >= 2:
			posthree = 1
			for j in range(1, 4):
				posthree *= pos[-j]
			for j in range(1, 3):
				posthree *= neg[-j]
		if len(pos) >= 1 and len(neg) >= 4:
			posone = pos[-1]
			for j in range(1, 5):
				posone *= neg[-j]
		ans = max(posone, posthree, posfive)
	print(ans)


a = int(input())

def prod(arr):
	a = 1
	for i in arr[0:5]:
		a = a * i
	return a

def lastprod(arr):
	a = 1
	arr = arr[::-1]
	for i in arr[0:5]:
		a = a * i
	return a
for i in range(a):
	b = int(input())
	arr = list(map(int, input().split()))
	pos = []
	arr.sort()
	arr = arr[::-1]
	neg = []
	for i in arr:
		if i < 0:
			neg.append(i)
		else:
			pos.append(i)
	pos.sort()
	pos = pos[::-1]
	neg.sort()
	if len(arr) == 5:
		print(prod(arr))
	else:
		anr = [prod(arr)]
		if len(neg) >= 2 and len(pos) >= 3:
			anr.append(neg[0] * neg[1] * pos[0] * pos[1] * pos[2])
		if len(neg) >= 4 and len(pos) >= 1:
			anr.append(neg[0] * neg[1] * neg[2] * neg[3] * pos[0])
		if len(neg) >= 5 and len(pos) == 0:
			anr.append(lastprod(arr))
		print(max(anr))


for _ in range(int(input())):
	n = int(input())
	c = list(map(int, input().split()))
	(pos, neg) = ([], [])
	for i in range(n):
		if c[i] < 0:
			neg.append(abs(c[i]))
		elif c[i] > 0:
			pos.append(c[i])
	neg = sorted(neg)[::-1]
	pos = sorted(pos)[::-1]
	ans1 = -1
	if len(pos) >= 5:
		ans1 = 1
		for i in range(5):
			ans1 *= pos[i]
	ans2 = -1
	if len(pos) >= 3 and len(neg) >= 2:
		ans2 = 1
		for i in range(3):
			ans2 *= pos[i]
		for i in range(2):
			ans2 *= neg[i]
	ans3 = -1
	if len(pos) >= 1 and len(neg) >= 4:
		ans3 = 1
		for i in range(1):
			ans3 *= pos[i]
		for i in range(4):
			ans3 *= neg[i]
	if len(neg) == len(c):
		ans = -1
		neg = neg[::-1]
		for i in range(5):
			ans *= neg[i]
		print(ans)
	elif len(c) == 5:
		ans = 1
		for i in range(5):
			ans *= c[i]
		print(ans)
	else:
		print(max(0, ans1, ans2, ans3))


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
from bisect import bisect_left
from functools import reduce
from operator import mul

def ml(array):
	return reduce(mul, array)
for __ in range(itg()):
	itg()
	arr = list(mpint())
	arr.sort()
	stack = [[], [], []]
	for a in arr:
		if a < 0:
			stack[0].append(a)
		elif a == 0:
			stack[1].append(0)
		else:
			stack[2].append(a)
	(neg, zero, pos) = stack
	neg.reverse()
	if len(neg) + len(pos) < 5:
		print(0)
		continue
	if len(pos) == 0:
		print(ml(neg[:5]) if not zero else 0)
		continue
	ans = -int(1e+20) if not zero else 0
	if len(pos) >= 5:
		ans = ml(pos[-5:])
	if len(neg) >= 2 and len(pos) >= 3:
		ans = max(ans, ml(neg[-2:]) * ml(pos[-3:]))
	if len(neg) >= 4 and pos:
		ans = max(ans, ml(neg[-4:]) * pos[-1])
	if len(neg) == 1 and len(pos) >= 4:
		ans = max(ans, neg[-1] * ml(pos[:4]))
	if len(neg) == 3 and len(pos) >= 2:
		ans = max(ans, ml(neg[:3]) * ml(pos[:2]))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	k = 5
	product = 1
	if arr[n - 1] == 0:
		print(0)
		continue
	if arr[n - 1] <= 0:
		for x in range(n - 5, n):
			product = product * arr[x]
		print(product)
		continue
	i = 0
	j = n - 1
	product = product * arr[j]
	j -= 1
	k -= 1
	k >>= 1
	for k in range(k):
		left_product = arr[i] * arr[i + 1]
		right_product = arr[j] * arr[j - 1]
		if left_product > right_product:
			product = product * left_product
			i += 2
		else:
			product = product * right_product
			j -= 2
	print(product)


for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	kek1 = [-10 ** 30] * 5
	kek2 = [10 ** 30] * 5
	kek3 = [-10 ** 30] * 5
	for elem in ar:
		if elem >= 0:
			if kek1[-1] < elem:
				kek1[-1] = elem
				kek1.sort(reverse=True)
		elif elem < 0:
			if kek2[-1] > elem:
				kek2[-1] = elem
				kek2.sort()
			if kek3[-1] < elem:
				kek3[-1] = elem
				kek3.sort(reverse=True)
	a = kek1[0] * kek2[0] * kek2[1] * kek2[2] * kek2[3]
	b = kek1[0] * kek1[1] * kek1[2] * kek2[0] * kek2[1]
	c = kek1[0] * kek1[1] * kek1[2] * kek1[3] * kek1[4]
	d = kek3[0] * kek3[1] * kek3[2] * kek3[3] * kek3[4]
	e = kek1[0] * kek1[1] * kek2[0] * kek2[1] * kek2[2]
	f = kek1[0] * kek1[1] * kek1[2] * kek1[3] * kek2[0]
	g = kek2[0] * kek2[1] * kek2[2] * kek2[3] * kek2[4]
	kek = [a, b, c, d, e, f, g]
	kek.sort(reverse=True)
	for elem in kek:
		if abs(elem) < 10 ** 25:
			print(elem)
			break


for _ in range(int(input())):
	n = int(input())
	neg = []
	pos = []
	zero = False
	for e in map(int, input().split()):
		if e < 0:
			neg.append(e)
		elif e > 0:
			pos.append(e)
		else:
			zero = True
	neg.sort()
	pos.sort()
	res = -float('inf')
	if zero:
		res = 0
	for i in range(6):
		if len(neg) < i or len(pos) < 5 - i:
			continue
		ar = neg[-i:] + pos[:5 - i]
		if i % 2 == 0:
			ar = neg[:i] + pos[-(5 - i):]
		acc = 1
		for e in ar:
			acc *= e
		res = max(res, acc)
	print(res)


t = int(input())
h = 1
while h <= t:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a = arr[n - 5] * arr[n - 4] * arr[n - 3] * arr[n - 2] * arr[n - 1]
	b = arr[n - 3] * arr[n - 2] * arr[n - 1] * arr[0] * arr[1]
	c = arr[n - 1] * arr[0] * arr[1] * arr[2] * arr[3]
	k = max(a, max(b, c))
	print(k)
	h += 1


gans = []
INF = 100000000000000000000000000000000000000
for i in range(int(input())):
	n = int(input())
	inp = list(map(int, input().split()))
	if n == 5:
		ans = 1
		for i in range(n):
			ans *= inp[i]
		gans.append(ans)
		continue
	u = []
	w = []
	z = []
	for i in range(n):
		if inp[i] > 0:
			u.append(inp[i])
		elif inp[i] < 0:
			w.append(inp[i])
		else:
			z.append(inp[i])
	u.sort(reverse=1)
	w.sort()
	ans1 = ans2 = ans3 = ans4 = ans5 = -INF
	if len(u) > 0 and len(w) > 3:
		ans1 = u[0] * w[0] * w[1] * w[2] * w[3]
	if len(u) > 2 and len(w) > 1:
		ans2 = u[0] * u[1] * u[2] * w[0] * w[1]
	if len(u) > 4:
		ans3 = u[0] * u[1] * u[2] * u[3] * u[4]
	if len(z) > 0:
		ans5 = 0
	if len(w) > 4:
		ans4 = w[-1] * w[-2] * w[-3] * w[-4] * w[-5]
	gans.append(max(ans1, ans2, ans3, ans4, ans5))
if -INF in gans:
	print(1 / 0)
print('\n'.join(map(str, gans)))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	pos = []
	neg = []
	zero = 0
	for i in l:
		if i > 0:
			pos.append(i)
		elif i < 0:
			neg.append(i)
		else:
			zero = 1
	pos.sort(reverse=True)
	neg.sort()
	lp = len(pos)
	np = len(neg)
	ans = float('-inf')
	if lp + np < 5:
		ans = 0
	if lp >= 5:
		r = pos[0] * pos[1] * pos[2] * pos[3] * pos[4]
		ans = max(ans, r)
	if np >= 5:
		r = neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5]
		ans = max(ans, r)
	if lp >= 3 and np >= 2:
		r = neg[0] * neg[1] * pos[0] * pos[1] * pos[2]
		ans = max(ans, r)
	if np >= 4 and lp >= 1:
		r = neg[0] * neg[1] * neg[2] * neg[3] * pos[0]
		ans = max(ans, r)
	if lp >= 4 and np >= 1:
		r = pos[-1] * pos[-2] * pos[-3] * pos[-4] * neg[-1]
		ans = max(ans, r)
	if lp >= 2 and np >= 3:
		r = neg[-1] * neg[-2] * neg[-3] * pos[-1] * pos[-2]
		ans = max(ans, r)
	if ans < 0:
		if zero == 1:
			ans = 0
	print(ans)


def solve(a):
	n = len(a)
	sol = a[0] * a[1] * a[2] * a[3] * a[5]
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				for x in range(k + 1, n):
					for y in range(x + 1, n):
						sol = max(sol, a[i] * a[j] * a[k] * a[x] * a[y])
	return sol
t = int(input(''))
arr = []
for i in range(t):
	n = int(input(''))
	arr.append(list(map(int, input().split())))
for i in arr:
	sol = 1
	if len(i) == 5:
		for j in i:
			sol *= j
		print(sol)
		continue
	if len(i) <= 10:
		print(solve(i))
		continue
	i.sort()
	sol = []
	n = len(i)
	for j in range(0, 5):
		sol.append(i[j])
	for j in range(n - 1, n - 6, -1):
		sol.append(i[j])
	print(solve(sol))


n = int(input())
while n:
	x = int(input())
	ans = 1
	temp = 1
	arr = sorted([int(i) for i in input().split()])
	a = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	b = arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3]
	c = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	print(max(a, b, c))
	n -= 1


from itertools import permutations, combinations
from functools import reduce
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	low = a[:5]
	high = a[-5:]
	if n <= 10:
		combined = a
	else:
		combined = low + high
	best = -float('inf')
	for p in combinations(combined, 5):
		mul = reduce(lambda a, b: a * b, p)
		best = max(best, mul)
	print(best)


import sys

def main():
	tn = int(input())
	for ti in range(tn):
		n = int(input())
		A = sorted((int(a) for a in input().split()))
		ans0 = A[-1] * A[-2] * A[-3] * A[-4] * A[-5]
		ans1 = A[-1] * A[0] * A[1] * A[2] * A[3]
		ans2 = A[-1] * A[-2] * A[-3] * A[0] * A[1]
		ans3 = A[-1] * A[-2] * A[0] * A[1] * A[2]
		ans4 = A[-1] * A[0] * A[1] * A[2] * A[3]
		print(max(ans0, ans1, ans2, ans3, ans4))
main()


import sys

def product(lst):
	prod = lst[0]
	for i in range(1, len(lst)):
		prod *= lst[i]
	return prod

def answer2(n, a):
	if n == 5:
		return product(a)
	a.sort(reverse=True)
	lst = []
	lst.append(a[0])
	lptr = 1
	rptr = n - 1
	while len(lst) < 5:
		lprod = a[lptr] * a[lptr + 1]
		rprod = a[rptr] * a[rptr - 1]
		if lprod >= rprod or a[0] < 0:
			lst.append(a[lptr])
			lst.append(a[lptr + 1])
			lptr += 2
		else:
			lst.append(a[rptr])
			lst.append(a[rptr - 1])
			rptr -= 2
	return product(lst)

def main():
	t = int(input())
	while t:
		n = int(sys.stdin.readline())
		a = [int(i) for i in sys.stdin.readline().split()]
		print(answer2(n, a))
		t -= 1
	return
main()


t = int(input())
for t1 in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	s = -1000000000000000000
	if n <= 10:
		for i1 in range(0, n):
			for i2 in range(i1 + 1, n):
				for i3 in range(i2 + 1, n):
					for i4 in range(i3 + 1, n):
						for i5 in range(i4 + 1, n):
							x = a[i1] * a[i2] * a[i3] * a[i4] * a[i5]
							s = max(s, x)
	else:
		a.sort()
		b = []
		for i in range(0, 5):
			b.append(a[i])
		for i in range(len(a) - 5, len(a)):
			b.append(a[i])
		n = len(b)
		for i1 in range(0, n):
			for i2 in range(i1 + 1, n):
				for i3 in range(i2 + 1, n):
					for i4 in range(i3 + 1, n):
						for i5 in range(i4 + 1, n):
							x = b[i1] * b[i2] * b[i3] * b[i4] * b[i5]
							s = max(s, x)
	print(s)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	pl = []
	zr = 0
	mn = []
	for x in a:
		if x > 0:
			pl.append(x)
		elif x == 0:
			zr += 1
		else:
			mn.append(x)
	pl.sort()
	mn.sort()
	res = -float('inf')
	if zr:
		res = 0
	for i in range(6):
		if len(pl) < i or len(mn) < 5 - i:
			continue
		t = 1
		if (5 - i) % 2:
			for x in range(i):
				t *= pl[x]
			for x in range(5 - i):
				t *= mn[-1 - x]
		else:
			for x in range(i):
				t *= pl[-1 - x]
			for x in range(5 - i):
				t *= mn[x]
		res = max(res, t)
	print(res)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, A):
	best = -float('inf')
	if 0 in A:
		best = 0
	neg = [x for x in A if x < 0]
	pos = [x for x in A if x >= 0]
	neg.sort()
	pos.sort(reverse=True)

	def product(arr):
		ret = 1
		for x in arr:
			ret *= x
		return ret
	for numNeg in range(5 + 1):
		numPos = 5 - numNeg
		if numNeg > len(neg):
			continue
		if numPos > len(pos):
			continue
		if numNeg % 2 == 0:
			best = max(best, product(neg[:numNeg]) * product(pos[:numPos]))
		else:
			best = max(best, product(neg[len(neg) - numNeg:]) * product(pos[len(pos) - numPos:]))
	return best
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, A)
	print(ans)


from functools import reduce
import operator

def prod(iterable):
	return reduce(operator.mul, iterable, 1)
T = int(input())
for _ in range(T):
	n = input()
	aa = sorted(map(int, input().split()))
	an = sorted((x for x in aa if x < 0))
	ap = sorted((x for x in aa if x > 0))
	az = sorted((x for x in aa if x == 0))
	nn = len(an)
	np = len(ap)
	ans = prod(aa[-5:])
	if np >= 5:
		ans = max(ans, prod(ap[-5:]))
	if np >= 3 and nn >= 2:
		ans = max(ans, prod(ap[-3:]) * prod(an[:2]))
	if np >= 1 and nn >= 4:
		ans = max(ans, ap[-1] * prod(an[:4]))
	if nn >= 5:
		ans = max(ans, prod(an[-5:]))
	if az:
		ans = max(ans, 0)
	print(ans)


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = sorted(map(int, stdin.readline().split()))
	res = a[-1]
	i = 0
	j = -2
	for _ in range(2):
		if res * a[i] * a[i + 1] > res * a[j] * a[j - 1]:
			res *= a[i] * a[i + 1]
			i += 2
		else:
			res *= a[j] * a[j - 1]
			j -= 2
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	k = sorted(map(int, input().strip().split()))
	(a, b) = (k[0] * k[1], k[2] * k[3])
	(c, d) = (k[-5] * k[-4], k[-3] * k[-2])
	e = k[-1]
	print(max(a * b * e, a * d * e, c * d * e))


TC = int(input())
for tc in range(TC):
	N = int(input())
	A = list(map(int, input().split()))
	pc = 0
	mc = 0
	A.sort()
	for i in range(1, 6):
		if A[-i] >= 0:
			pc += 1
	for i in range(5):
		if A[i] < 0:
			mc += 1
	result = -10 ** 20
	if mc > 3:
		result = max(A[0] * A[1] * A[2] * A[3] * A[-1], result)
	if mc > 1:
		result = max(A[0] * A[1] * A[-2] * A[-3] * A[-1], result)
	result = max(A[-5] * A[-4] * A[-2] * A[-3] * A[-1], result)
	print(result)


from sys import stdin, stdout

def main():
	t = int(stdin.readline())
	for _ in range(t):
		n = int(stdin.readline())
		a = [int(i) for i in stdin.readline().split()]
		lp = [[0] * 5 for i in range(n)]
		sp = [[0] * 5 for i in range(n)]
		lp[0][0] = a[0]
		sp[0][0] = a[0]
		for i in range(1, n):
			for k in range(min(5, i + 1)):
				c = []
				if k != i:
					c1 = lp[i - 1][k]
					c2 = sp[i - 1][k]
					c.append(c1)
					c.append(c2)
				if k != 0:
					c3 = a[i] * lp[i - 1][k - 1]
					c4 = a[i] * sp[i - 1][k - 1]
					c.append(c3)
					c.append(c4)
				if k == 0:
					c5 = a[i]
					c.append(c5)
				lp[i][k] = max(c)
				sp[i][k] = min(c)
		print(lp[n - 1][4])
main()


from sys import stdin

class Input:

	def __init__(self):
		self.next = self.readline()

	def readline(self):
		return stdin.readline().strip()

	def line(self):
		try:
			return self.next
		finally:
			self.next = self.readline()

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

	def known_tests(self):
		(num_of_cases,) = self.array()
		for case in range(num_of_cases):
			yield self

	def unknown_tests(self):
		while self.next:
			yield self

class Problem:

	def __init__(self, input):
		(n,) = input.array()
		a = input.array()
		a.sort()
		ans = max(a[0] * a[1] * a[2] * a[3] * a[4], a[0] * a[1] * a[2] * a[3] * a[-1], a[0] * a[1] * a[2] * a[-2] * a[-1], a[0] * a[1] * a[-3] * a[-2] * a[-1], a[0] * a[-4] * a[-3] * a[-2] * a[-1], a[-5] * a[-4] * a[-3] * a[-2] * a[-1])
		print(ans)
for tc in Input().known_tests():
	Problem(tc)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	prod = 1
	if len(arr) == 5:
		for i in arr:
			prod *= i
		print(prod)
		continue
	if arr[0] >= 0 or arr[-1] <= 0:
		for i in arr[-1:-6:-1]:
			prod *= i
		print(prod)
		continue
	prod1 = arr[0] * arr[1]
	prod2 = arr[2] * arr[3]
	prod3 = arr[-1] * arr[-2]
	prod4 = arr[-3] * arr[-4]
	p1 = prod1 * prod2 * arr[-1]
	p2 = prod1 * prod3 * arr[-3]
	p3 = prod3 * prod4 * arr[-5]
	print(max(p1, p2, p3))


def read(datatype=int):
	return datatype(input())

def readl(datatype=int):
	return list(map(datatype, input().split()))

def printl(data):
	string = ''
	for d in data:
		string += str(d) + ' '
	print(string)

def testcase():
	n = read()
	arr = readl()
	arr.sort()
	ans = max([arr[0] * arr[1] * arr[2] * arr[3] * arr[-1], arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3], arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]])
	print(ans)
	return
t = read()
for _ in range(t):
	testcase()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	count = 1
	maxi = -9999999999999999999999999999
	k = n - 5
	for i in range(5):
		for j in range(5):
			count *= a[(n - 5 + i + j) % n]
		maxi = max(maxi, count)
		count = 1
	print(maxi)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().rstrip('\n\r')
from functools import reduce

def mul(a):
	if a == []:
		return 1
	return reduce(lambda x, y: x * y, a)
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	ar = inar()
	pos = []
	neg = []
	for i in ar:
		if i < 0:
			neg.append(i)
		else:
			pos.append(i)
	neg.sort()
	pos.sort()
	ans = -float('inf')
	for k in range(6):
		p = k
		ne = 5 - k
		if len(pos) >= p and len(neg) >= ne:
			if ne % 2 == 0:
				ans = max(ans, mul(pos[-p:]) * mul(neg[:ne]))
			else:
				ans = max(ans, mul(pos[-p:]) * mul(neg[-ne:]))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(lower, higher) = ([], [])
	zeros = False
	for i in arr:
		if i < 0:
			lower.append(i)
		elif i > 0:
			higher.append(i)
		else:
			zeros = True
	lower.sort()
	higher.sort(reverse=True)
	if len(higher) >= 5:
		a = higher[0] * higher[1] * higher[2] * higher[3] * higher[4]
	else:
		a = -10 ** 18
	if len(lower) >= 2 and len(higher) >= 3:
		b = lower[0] * lower[1] * higher[0] * higher[1] * higher[2]
	else:
		b = -10 ** 18
	if len(lower) >= 4 and len(higher) >= 1:
		c = lower[0] * lower[1] * lower[2] * lower[3] * higher[0]
	else:
		c = -10 ** 18
	if len(lower) >= 1 and len(higher) >= 4:
		d = lower[-1] * higher[0] * higher[1] * higher[2] * higher[3]
	else:
		d = -10 ** 18
	if len(lower) >= 3 and len(higher) >= 2:
		e = lower[-1] * lower[-2] * lower[-3] * higher[0] * higher[1]
	else:
		e = -10 ** 18
	if len(lower) >= 5:
		f = lower[-1] * lower[-2] * lower[-3] * lower[-4] * lower[-5]
	else:
		f = -10 ** 18
	ans = max(a, b, c, d, e, f)
	if zeros:
		ans = max(ans, 0)
	print(ans)


for x in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	m.sort(reverse=True)
	a = []
	k = 1
	for i in range(5):
		k *= m[i]
		if i == 2:
			j = k
	a.append(k)
	k = m[0]
	for i in range(n - 1, n - 5, -1):
		k *= m[i]
	a.append(k)
	j *= m[-1] * m[-2]
	a.append(j)
	print(max(a))


from io import BytesIO, IOBase
import sys
import os
import math
import random
import bisect
import heapq
from fractions import Fraction
from collections import defaultdict, Counter
mod1 = 100000007
mod2 = 99824435
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def make_nCr_mod(max_n=2 * 10 ** 5, mod=10 ** 9 + 7):
	max_n = min(max_n, mod - 1)
	(fact, inv_fact) = ([0] * (max_n + 1), [0] * (max_n + 1))
	fact[0] = 1
	for i in range(max_n):
		fact[i + 1] = fact[i] * (i + 1) % mod
	inv_fact[-1] = pow(fact[-1], mod - 2, mod)
	for i in reversed(range(max_n)):
		inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod

	def nCr_mod(n, r):
		res = 1
		while n or r:
			(a, b) = (n % mod, r % mod)
			if a < b:
				return 0
			res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
			n //= mod
			r //= mod
		return res
	return nCr_mod

def poly(a, x):
	val = 0
	for ai in reversed(a):
		val *= x
		val += ai
	return val

def diff(a):
	return [a[i + 1] * (i + 1) for i in range(len(a) - 1)]

def divroot(a, x0):
	(b, a[-1]) = (a[-1], 0)
	for i in reversed(range(len(a) - 1)):
		(a[i], b) = (a[i + 1] * x0 + b, a[i])
		a.pop()
	return a

def binary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		mi = lo + (hi - lo) / 2
		if func(mi):
			hi = mi
		else:
			lo = mi
	return (lo + hi) / 2

def ternary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		lo_third = lo + (hi - lo) / 3
		hi_third = hi - (hi - lo) / 3
		if func(lo_third) < func(hi_third):
			lo = lo_third
		else:
			hi = hi_third
	return (lo + hi) / 2

def discrete_binary_search(func, lo, hi):
	while lo < hi:
		mi = lo + (hi - lo) // 2
		if func(mi):
			hi = mi
		else:
			lo = mi + 1
	return lo

def discrete_ternary_search(func, lo, hi):
	while lo <= hi:
		lo_third = lo + (hi - lo) // 3
		hi_third = lo + (hi - lo) // 3 + (1 if 0 < hi - lo < 3 else (hi - lo) // 3)
		if func(lo_third) < func(hi_third):
			lo = lo_third + 1
		else:
			hi = hi_third - 1
	return lo

def fractional_binary_search(func, lo=(0, 1), hi=(1, 0), limit=1000000):
	if func(lo):
		return lo
	flag = True
	(A, B) = (1, 1)
	while A or B:
		(adv, step) = (0, 1)
		si = 0
		while step:
			adv += step
			mid = (lo[0] * adv + hi[0], lo[1] * adv + hi[1])
			if abs(mid[0]) > limit or mid[1] > limit or flag != func(mid):
				adv -= step
				si = 2
			step += step
			step >>= si
		flag = not flag
		(lo, hi) = ((hi[0] + lo[0] * adv, hi[1] + lo[1] * adv), lo)
		(A, B) = (B, adv)
	return hi if flag else lo

def golden_section_search(a, b, func, abs_prec=1e-07):
	r = (5 ** 0.5 - 1) / 2
	x1 = b - r * (b - a)
	f1 = func(b - r * (b - a))
	x2 = a + r * (b - a)
	f2 = func(a + r * (b - a))
	while b - a > abs_prec:
		if f1 < f2:
			(b, x2, f2) = (x2, x1, f1)
			x1 = b - r * (b - a)
			f1 = func(b - r * (b - a))
		else:
			(a, x1, f1) = (x1, x2, f2)
			x2 = a + r * (b - a)
			f2 = func(a + r * (b - a))
	return a

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	print(max(a[-1] * a[-2] * a[-3] * a[-4] * a[-5], a[0] * a[1] * a[-1] * a[-2] * a[-3], a[0] * a[1] * a[2] * a[3] * a[-1]))


game = int(input())
for i in range(game):
	number = int(input())
	j = number
	i = 0
	list = []
	list = map(int, input().split())
	list = sorted(list)
	positive = []
	negative = []
	mul = 1
	final = 0
	for value in list:
		if value >= 0:
			positive.append(value)
		else:
			negative.append(value)
	p5 = list[j - 1] * list[j - 2] * list[j - 3] * list[j - 4] * list[j - 5]
	if len(negative) == 0 or len(negative) == 1:
		final = p5
	elif len(negative) >= 2 and len(negative) < 4:
		n2 = negative[0] * negative[1]
		p3 = list[j - 1] * list[j - 2] * list[j - 3]
		final = max(n2 * p3, p5)
	elif len(negative) >= 4:
		n4 = negative[0] * negative[1] * negative[2] * negative[3]
		final = max(n4 * list[j - 1], negative[0] * negative[1] * list[j - 1] * list[j - 2] * list[j - 3], p5)
	print(final)


for i in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	A = sorted(A)
	ans = []
	ans.append(A[0] * A[1] * A[2] * A[3] * A[4])
	ans.append(A[0] * A[1] * A[2] * A[3] * A[-1])
	ans.append(A[0] * A[1] * A[2] * A[-2] * A[-1])
	ans.append(A[0] * A[1] * A[-3] * A[-2] * A[-1])
	ans.append(A[0] * A[-4] * A[-3] * A[-2] * A[-1])
	ans.append(A[-5] * A[-4] * A[-3] * A[-2] * A[-1])
	print(max(ans))


import math

def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	l = 0
	r = n - 1
	num = 5
	ret = 1
	if arr[n - 1] < 0:
		ret = arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5]
	else:
		while num > 0:
			negative = -1
			positive = 1
			if num >= 2:
				negative = arr[l] * arr[l + 1]
				positive = arr[r] * arr[r - 1]
				if negative > positive:
					ret *= negative
					l += 2
					num -= 2
				else:
					ret *= arr[r]
					r -= 1
					num -= 1
			elif ret > 0:
				ret *= arr[r]
				r -= 1
				num -= 1
			else:
				ret *= arr[l]
				l += 1
				num -= 1
	print(str(ret))
n = int(input())
for i in range(0, n):
	solve()


def prod(l):
	result = 1
	for j in l:
		result *= j
	return result
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = len(list(filter(lambda x: x > 0, l)))
	l.sort()
	final = []
	if x == 0:
		final = prod(l[-1:-6:-1])
	elif x <= 2:
		final = prod(l[0:4] + l[-1:])
	elif x <= 4:
		final = max(prod(l[0:4] + l[-1:]), prod(l[0:2] + l[-1:-4:-1]))
	else:
		final = max(prod(l[0:4] + l[-1:]), prod(l[0:2] + l[-1:-4:-1]), prod(l[-1:-6:-1]))
	print(final)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	zero = False
	np = 0
	pos = []
	nn = 0
	neg = []
	for i in range(n):
		if arr[i] > 0:
			np += 1
			pos.append(arr[i])
		elif arr[i] < 0:
			nn += 1
			neg.append(arr[i])
		else:
			zero = True
	pos.sort(reverse=True)
	neg.sort()
	ans = []
	for i in range(5):
		if np >= 5 - i and nn >= i:
			temp = 1
			for j in range(5 - i):
				temp *= pos[j]
			for j in range(i):
				temp *= neg[j]
			ans.append(temp)
	if nn >= 5:
		temp = 1
		for i in range(5):
			temp *= neg[nn - 1 - i]
		ans.append(temp)
	if zero:
		ans.append(0)
	print(max(ans))


from collections import Counter
y122 = int(input())
for _ in range(y122):
	a = input()
	a = list(map(int, input().strip().split()))
	n = []
	z = 0
	p = []
	for i in range(len(a)):
		if a[i] < 0:
			n.append(a[i])
		if a[i] == 0:
			z += 1
		if a[i] >= 0:
			p.append(a[i])
	n.sort()
	p.sort(reverse=True)
	ans = []
	try:
		ans.append(n[-1] * n[-2] * n[-3] * n[-4] * n[-5])
	except:
		fuddu = 1
	try:
		ans.append(n[0] * n[1] * n[2] * n[3] * p[0])
	except:
		fuddu = 1
	try:
		ans.append(n[-1] * n[-2] * n[-3] * p[-1] * p[-2])
	except:
		fuddu = 1
	try:
		ans.append(n[0] * n[1] * p[0] * p[1] * p[2])
	except:
		fuddu = 1
	try:
		ans.append(n[-1] * p[-1] * p[-2] * p[-3] * p[-4])
	except:
		fuddu = 1
	try:
		ans.append(p[4] * p[0] * p[1] * p[2] * p[3])
	except:
		fuddu = 1
	print(max(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	p1 = l[-1]
	p2 = p3 = 1
	for i in range(4):
		p1 = p1 * l[i]
	for i in range(n - 1, n - 6, -1):
		p2 = p2 * l[i]
	p3 = l[0] * l[1]
	for i in range(n - 1, n - 4, -1):
		p3 = p3 * l[i]
	print(max(max(p1, p2), p3))


from collections import defaultdict as dd
for _ in range(int(input())):
	n = int(input())
	d = list(map(int, input().split()))
	a = sorted(d, key=lambda x: abs(x))
	flag = f = False
	cnt = 0
	neg = 0
	negg = 1
	for i in range(n):
		if a[i] > 0:
			flag = True
		if a[i] == 0:
			f = True
	if flag == False:
		if f == True:
			print(0)
		else:
			print(a[0] * a[1] * a[3] * a[4] * a[2])
	else:
		f3 = True
		ans = [a[0] * a[1] * a[2] * a[3] * a[4]]
		pos = []
		neg = []
		poss = negg = 0
		for i in range(n - 1, -1, -1):
			if a[i] >= 0:
				pos.append(a[i])
				poss += 1
			else:
				neg.append(a[i])
				negg += 1
		if negg >= 4 and poss > 0:
			ans.append(neg[0] * neg[1] * neg[2] * neg[3] * pos[0])
		if negg >= 2 and poss > 2:
			ans.append(neg[0] * neg[1] * pos[0] * pos[1] * pos[2])
		if poss > 4:
			ans.append(pos[0] * pos[1] * pos[2] * pos[3] * pos[4])
		print(max(ans))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	a.sort()
	ans.append(a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5])
	ans.append(a[0] * a[1] * a[n - 3] * a[n - 2] * a[n - 1])
	ans.append(a[0] * a[1] * a[2] * a[3] * a[n - 1])
	ans.append(a[0] * a[1] * a[2] * a[3] * a[4])
	return max(ans)
t = int(input())
while t != 0:
	print(solve())
	t -= 1


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	n = int(ii())
	data = sorted(idata())
	ans1 = -1
	ans2 = -1
	if data[0] < 0 and data[1] < 0:
		ans1 = data[0] * data[1]
		if data[2] < 0 and data[3] < 0:
			ans2 = ans1 * data[2] * data[3]
	if ans1 != -1 and ans2 != -1:
		print(max(ans1 * data[-1] * data[-2] * data[-3], ans2 * data[-1], data[-1] * data[-2] * data[-3] * data[-4] * data[-5]))
	elif ans1 == -1 and ans2 != -1:
		print(max(ans2 * data[-1], data[-1] * data[-2] * data[-3] * data[-4] * data[-5]))
	elif ans2 == -1 and ans1 != -1:
		print(max(ans1 * data[-1] * data[-2] * data[-3], data[-1] * data[-2] * data[-3] * data[-4] * data[-5]))
	else:
		print(data[-1] * data[-2] * data[-3] * data[-4] * data[-5])
	return
for t in range(int(ii())):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 5:
		print(a[0] * a[1] * a[2] * a[3] * a[4])
	else:
		a.sort()
		m1 = a[0] * a[1] * a[2] * a[3] * a[-1]
		m2 = a[-5] * a[-4] * a[-3] * a[-2] * a[-1]
		m3 = a[0] * a[1] * a[-3] * a[-2] * a[-1]
		print(max(m1, m2, m3))


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort(reverse=True)
	m1 = x[0] * x[-1] * x[-2] * x[-3] * x[-4]
	m2 = x[-5] * x[-1] * x[-2] * x[-3] * x[-4]
	m3 = x[0] * x[1] * x[2] * x[-2] * x[-1]
	m4 = x[0] * x[1] * x[2] * x[3] * x[4]
	print(max(m1, m2, m3, m4))


import sys
input = sys.stdin.buffer.readline
T = int(input())
for testcase in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	res = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	b = 1
	tmp = 1
	for i in range(5):
		tmp = tmp * a[i]
		b = 1
		for j in range(4 - i):
			b *= a[n - 1 - j]
		res = max(res, tmp * b)
	print(res)


t = int(input())
outputs = []
for i in range(t):
	amount = int(input())
	items = [int(i) for i in input().split()]
	if amount == 5:
		outputs.append(items[0] * items[1] * items[2] * items[3] * items[4])
	else:
		items.sort()
		outputs.append(max(items[0] * items[1] * items[2] * items[3] * items[-1], items[0] * items[1] * items[-1] * items[-2] * items[-3], items[-1] * items[-2] * items[-3] * items[-4] * items[-5]))
for out in outputs:
	print(out)


mod = 10 ** 9 + 7

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	not_null = 0
	ans = 0
	for x in a:
		if x != 0:
			not_null += 1
	if a[n - 1] == 0 or not_null < 5:
		ans = 0
	elif a[n - 1] < 0:
		ans = 1
		a = a[::-1]
		for i in range(5):
			ans *= a[i]
	else:
		ans = a[n - 1]
		tmp1 = 1
		tmp2 = 1
		tmp3 = 1
		for i in range(4):
			tmp1 *= a[i]
			tmp2 *= a[n - i - 2]
			if i < 2:
				tmp3 *= a[i]
			else:
				tmp3 *= a[n - i]
		ans = max(ans * tmp1, ans * tmp2, ans * tmp3)
	print(ans)
t = int(input())
while t > 0:
	solve()
	t -= 1


t = int(input())
while t > 0:
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	ans1 = li[n - 1] * li[n - 2] * li[n - 3] * li[n - 4] * li[n - 5]
	ans2 = li[n - 1] * li[n - 2] * li[n - 3] * li[0] * li[1]
	ans3 = li[0] * li[1] * li[2] * li[3] * li[n - 1]
	ans = max(ans1, ans2, ans3)
	print(ans)
	t -= 1
	pass


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = ria()
		neg = []
		pos = []
		for i in a:
			if i < 0:
				neg.append(-i)
			else:
				pos.append(i)
		z = sorted(neg)
		g = sorted(pos)
		neg = z[::-1]
		pos = g[::-1]
		(a1, b1, c1, d1, e1, f1) = (-99999999999999999999999999, -99999999999999999999999999, -99999999999999999999999999, -99999999999999999999999999, -99999999999999999999999999, -99999999999999999999999999)
		if len(neg) >= 2 and len(pos) >= 3:
			a1 = neg[0] * neg[1] * pos[0] * pos[1] * pos[2]
		if len(neg) >= 4 and len(pos) >= 1:
			b1 = neg[0] * neg[1] * neg[2] * neg[3] * pos[0]
		if len(neg) >= 1 and len(pos) >= 4:
			e1 = -z[0] * g[3] * g[0] * g[1] * g[2]
		if len(neg) >= 3 and len(pos) >= 2:
			f1 = -z[0] * z[1] * z[2] * g[1] * g[0]
		if len(pos) >= 5:
			c1 = pos[0] * pos[1] * pos[2] * pos[3] * pos[4]
		if len(neg) >= 5:
			d1 = -z[0] * z[1] * z[2] * z[3] * z[4]
		print(max(a1, b1, c1, d1, e1, f1))
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


def max5(N, S):
	Sp = []
	Sm = []
	S0 = []
	for i in range(N):
		if S[i] > 0:
			Sp.append(S[i])
		elif S[i] == 0:
			S0.append(0)
		else:
			Sm.append(S[i])
	Sp.sort(reverse=True)
	Sm.sort()
	Sp2 = sorted(Sp)
	Sm2 = sorted(Sm, reverse=True)
	ans = -10 ** 20
	A = []
	for i in range(6):
		if len(Sp) < i or len(Sm) < 5 - i:
			pass
		else:
			ans2 = 1
			if i % 2 == 1:
				A = Sp[:i]
				A = A + Sm[:5 - i]
			else:
				A = Sp2[:i]
				A = A + Sm2[:5 - i]
			for j in range(5):
				ans2 *= A[j]
			if ans < ans2:
				ans = ans2
	if ans < 0 and len(S0) > 0:
		ans = 0
	print(ans)
for i in range(int(input())):
	max5(int(input()), list(map(int, input().split())))


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()

def mul(x):
	an = 1
	for i in x:
		an *= i
	return an
for _ in range(t):
	(n,) = I()
	l = sorted(I())
	an = mul(l[:5])
	for i in range(6):
		j = 5 - i
		an = max(an, mul(l[:i]) * mul(l[n - j:]))
	print(an)


for t in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	m.sort()
	res = -10 ** 20
	for i in range(5):
		ans = 1
		for j in range(i):
			ans = ans * m[j]
		for j in range(5 - i):
			ans = ans * m[n - j - 1]
		res = max(res, ans)
	print(res)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	print(max(a[0] * a[1] * a[-1] * a[-2] * a[-3], a[0] * a[1] * a[2] * a[3] * a[-1], a[-1] * a[-2] * a[-3] * a[-4] * a[-5]))


def prod(x):
	res = 1
	for _ in x:
		res *= _
	return res

def solve(N, A):
	A = sorted(A)
	if A[-1] <= 0 or N == 5:
		print(prod(A[-5:]))
		return
	(pos, neg) = (0, 0)
	for x in A:
		pos += x > 0
		neg += x < 0
	nol = N - (pos + neg)
	ans = -float('inf')
	if nol + pos >= 5:
		ans = max([ans, prod(A[-5:])])
	if nol + pos >= 3:
		ans = max([ans, prod(A[:2]) * prod(A[-3:])])
	if nol + pos >= 1:
		ans = max([ans, prod(A[:4]) * A[-1]])
	print(ans)

def main():
	T = int(input().strip())
	for _ in range(T):
		N = int(input().strip())
		A = list(map(int, input().strip().split()))
		solve(N, A)
main()


for _ in range(int(input())):
	z = int(input())
	l = list(map(int, input().split()))
	n = []
	p = []
	a = 0
	for i in l:
		if i < 0:
			n.append(i)
			a += 1
		else:
			p.append(i)
	n.sort()
	p.sort(reverse=True)
	ans = -1000000000000000000
	if z - a == 0:
		ans = n[-5] * n[-4] * n[-3] * n[-2] * n[-1]
	elif z == 5:
		ans = l[0] * l[1] * l[2] * l[3] * l[4]
	else:
		if a >= 4:
			ans = max(ans, n[0] * n[1] * n[2] * n[3] * p[0])
		if a >= 2 and z - a >= 3:
			ans = max(ans, n[0] * n[1] * p[2] * p[1] * p[0])
		if a >= 0 and z - a >= 5:
			ans = max(ans, p[4] * p[1] * p[2] * p[3] * p[0])
	print(ans)


from sys import stdin, exit, setrecursionlimit
from collections import deque
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	a = lmi()
	a.sort()
	if all((i <= 0 for i in a)):
		print(a[-5] * a[-4] * a[-3] * a[-2] * a[-1])
	else:
		print(max(a[0] * a[1] * a[-1] * a[-2] * a[-3], a[0] * a[1] * a[-1] * a[2] * a[3], a[-1] * a[-2] * a[-3] * a[-4] * a[-5]))


for t in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	a = l[-5] * l[-4] * l[-3] * l[-2] * l[-1]
	b = l[0] * l[1] * l[-3] * l[-2] * l[-1]
	c = l[0] * l[1] * l[2] * l[3] * l[-1]
	print(max(a, b, c))


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	if n == 5:
		print(A[0] * A[1] * A[2] * A[3] * A[4])
		continue
	P = []
	M = []
	Z = []
	for a in A:
		if a > 0:
			P.append(a)
		elif a < 0:
			M.append(-a)
		else:
			Z.append(0)
	P.sort(reverse=True)
	M.sort(reverse=True)
	if len(P) == 0:
		if len(Z) > 0:
			print(0)
			continue
		else:
			print(M[-1] * M[-2] * M[-3] * M[-4] * M[-5] * -1)
			continue
	MAX = 0
	if len(P) >= 5:
		MAX = max(MAX, P[0] * P[1] * P[2] * P[3] * P[4])
	if len(P) >= 3 and len(M) >= 2:
		MAX = max(MAX, P[0] * P[1] * P[2] * M[0] * M[1])
	if len(P) >= 1 and len(M) >= 4:
		MAX = max(MAX, P[0] * M[0] * M[1] * M[2] * M[3])
	print(MAX)


import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq
INF = 10 ** 20
MOD = 10 ** 9 + 7
ni = lambda : int(sys.stdin.readline().rstrip())
ns = lambda : map(int, sys.stdin.readline().rstrip().split())
na = lambda : list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda : list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
flush = lambda : sys.stdout.flush()

def main():
	t = ni()
	for _ in range(t):
		n = ni()
		a = na()
		ans = -INF
		a.sort()
		if 0 in a:
			ans = 0
		p1 = a[-1]
		m4 = a[0] * a[1] * a[2] * a[3]
		ans = max(ans, p1 * m4)
		p3 = a[-1] * a[-2] * a[-3]
		m2 = a[0] * a[1]
		ans = max(ans, p3 * m2)
		p5 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
		ans = max(ans, p5)
		print(ans)
main()


T = int(input())
for i in range(0, T):
	n = int(input())
	array = [int(s) for s in input().split()]
	array.sort()
	values = []
	values.append(array[0] * array[1] * array[n - 1] * array[n - 2] * array[n - 3])
	values.append(array[0] * array[1] * array[2] * array[3] * array[n - 1])
	values.append(array[n - 1] * array[n - 2] * array[n - 3] * array[n - 4] * array[n - 5])
	print(max(values))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = -1e+18 + 1
	for i in range(6):
		c = 1
		for j in range(i):
			c *= a[j]
		for j in range(5 - i):
			c *= a[n - j - 1]
		m = max(m, c)
	print(m)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	pos = []
	neg = []
	z = 0
	for i in a:
		if i > 0:
			pos.append(i)
		elif i < 0:
			neg.append(i)
		else:
			z += 1
	if n - z < 5:
		print(0)
		continue
	pos.sort(reverse=True)
	neg.sort()
	a1 = a[0] * a[1] * a[2] * a[3] * a[4]
	if len(pos) > 0 and len(neg) > 3:
		a3 = pos[0] * neg[0] * neg[1] * neg[2] * neg[3]
		a1 = max(a1, a3)
	if len(pos) > 1 and len(neg) > 2:
		a4 = pos[-1] * pos[-2] * neg[-3] * neg[-2] * neg[-1]
		a1 = max(a1, a4)
	if len(pos) > 2 and len(neg) > 1:
		a2 = pos[0] * pos[1] * pos[2] * neg[0] * neg[1]
		a1 = max(a1, a2)
	if len(pos) > 3 and len(neg) > 0:
		a4 = pos[-1] * pos[-2] * pos[-3] * pos[-4] * neg[-1]
		a1 = max(a1, a4)
	if len(neg) > 4:
		a5 = neg[-5] * neg[-4] * neg[-3] * neg[-2] * neg[-1]
		a1 = max(a1, a5)
	if a1 < 0 and z > 0:
		a1 = 0
	print(a1)


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	a.sort()
	x1 = a[0] * a[1] * a[2] * a[3] * a[4]
	x2 = a[0] * a[1] * a[2] * a[3] * a[-1]
	x3 = a[0] * a[1] * a[2] * a[-2] * a[-1]
	x4 = a[0] * a[1] * a[-3] * a[-2] * a[-1]
	x5 = a[0] * a[-4] * a[-3] * a[-2] * a[-1]
	x6 = a[-5] * a[-4] * a[-3] * a[-2] * a[-1]
	print(max(x1, x2, x3, x4, x5, x6))


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict, Counter
from os import path
import bisect as bi
import heapq

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def inp():
		return int(input())

	def minp():
		return map(int, input().split())
else:

	def inp():
		return int(stdin.readline())

	def minp():
		return map(int, stdin.readline().split())
for _ in range(inp()):
	n = inp()
	a = list(minp())
	a.sort()
	new = []
	for i in range(0, 6):
		total = 1
		for j in range(i):
			total *= a[j]
		for j in range(n - 1, n - (6 - i), -1):
			total *= a[j]
		new.append(total)
	print(max(new))


t = int(input())
List = []
for i in range(t):
	n = int(input())
	List = [int(s) for s in input().split()]
	List.sort()
	print(max(List[0] * List[1] * List[2] * List[3] * List[4], List[-1] * List[-2] * List[-3] * List[-4] * List[-5], List[0] * List[1] * List[2] * List[3] * List[-1], List[0] * List[1] * List[2] * List[-1] * List[-2], List[0] * List[1] * List[-3] * List[-2] * List[-1], List[0] * List[-4] * List[-3] * List[-2] * List[-1]))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(pos, neg) = (0, 0)
	for i in arr:
		if i > 0:
			pos += 1
		elif i < 0:
			neg += 1
	ans = -10 ** 18
	arr.sort()
	i = 0
	while i <= 4 and i <= neg:
		cur = 1
		for j in range(i):
			cur = cur * arr[j]
		j = n - 1
		while j >= n - (5 - i):
			cur = cur * arr[j]
			j -= 1
		ans = max(ans, cur)
		i += 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())), key=lambda x: abs(x), reverse=True)
	ok = False
	if a[0] * a[1] * a[2] * a[3] * a[4] > 0:
		ok = True
		print(a[0] * a[1] * a[2] * a[3] * a[4])
	else:
		ans = 0
		now = a[0] * a[1] * a[2] * a[3] * a[4]
		for fucc in range(4, -1, -1):
			for i in a[5:]:
				if i > 0 and a[fucc] < 0 or (i < 0 and a[fucc] > 0):
					ok = True
					ans = max(now // a[fucc] * i, ans)
					break
		if ok:
			print(ans)
	if not ok:
		print(a[-1] * a[-2] * a[-3] * a[-4] * a[-5])


mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = max(arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5], arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[0] * arr[1], arr[n - 1] * arr[0] * arr[1] * arr[2] * arr[3])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	if n == 5:
		print(l[0] * l[1] * l[2] * l[3] * l[4])
		continue
	neg_arr = []
	pos_arr = []
	for i in l:
		if i < 0:
			neg_arr.append(i)
		elif i > 0:
			pos_arr.append(i)
	if len(neg_arr) + len(pos_arr) < 5:
		print(0)
		continue
	neg_arr.sort()
	pos_arr.sort()
	arr = []
	if 0 in l:
		arr.append(0)
	if len(neg_arr) >= 2 and len(pos_arr) >= 3:
		arr.append(neg_arr[0] * neg_arr[1] * pos_arr[-1] * pos_arr[-2] * pos_arr[-3])
	if len(neg_arr) >= 4 and len(pos_arr) >= 1:
		arr.append(neg_arr[0] * neg_arr[1] * neg_arr[2] * neg_arr[3] * pos_arr[-1])
	if len(pos_arr) >= 5:
		arr.append(pos_arr[-1] * pos_arr[-2] * pos_arr[-3] * pos_arr[-4] * pos_arr[-5])
	if len(pos_arr) == 0:
		arr.append(neg_arr[-1] * neg_arr[-2] * neg_arr[-3] * neg_arr[-4] * neg_arr[-5])
	if len(pos_arr) == 4:
		arr.append(pos_arr[-1] * pos_arr[-2] * pos_arr[-3] * pos_arr[-4] * neg_arr[0])
	print(max(arr))


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from collections import deque
for _ in range(int(read())):
	n = int(read())
	nums = sorted(readi())
	ans = float('-inf')
	for i in range(5):
		a1 = (n - 1 + i) % n
		a2 = (n - 2 + i) % n
		a3 = (n - 3 + i) % n
		a4 = (n - 4 + i) % n
		a5 = (n - 5 + i) % n
		ans = max(ans, nums[a1] * nums[a2] * nums[a3] * nums[a4] * nums[a5])
	print(ans)


result = []
for i in range(int(input())):
	n = int(input()) - 1
	nos = list(map(int, input().split()))
	nos.sort()
	rhs = 0
	lhs = 0
	final = []
	chosed = 0
	if nos[n] < 0:
		final.append(n)
		final.append(n - 1)
		final.append(n - 2)
		final.append(n - 3)
		final.append(n - 4)
	else:
		while chosed < 5:
			if lhs + 1 not in final and chosed < 4 and (nos[lhs] * nos[lhs + 1] > nos[n - rhs] * nos[n - rhs - 1]):
				final.append(lhs)
				final.append(lhs + 1)
				lhs += 2
				chosed += 2
			else:
				final.append(n - rhs)
				rhs += 1
				chosed += 1
	r = nos[final[0]] * nos[final[1]] * nos[final[2]] * nos[final[3]] * nos[final[4]]
	result.append(str(r))
print('\n'.join(result))


for _ in range(int(input())):
	N = int(input())
	array = list(map(int, input().split()))
	array.sort()
	negatives = 0
	for i in array:
		if i < 0:
			negatives += 1
	positives = N - negatives
	products = []
	p1 = array[-1] * array[-2] * array[-3] * array[-4] * array[-5]
	products.append(p1)
	p1 = array[-1] * array[-2] * array[-3] * array[0] * array[1]
	products.append(p1)
	p1 = array[-1] * array[0] * array[1] * array[2] * array[3]
	products.append(p1)
	print(max(products))


import sys
import math
mod = 998244353
cases = True
dynamic_factorial = False

def main(test_case=False):
	n = int(input()) if test_case else 1
	for _ in range(n):
		test()
		print()

def fast_pow(a: int, b: int):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def c2(n):
	return n * (n - 1) // 2

def get():
	return list(map(int, input().split()))

def bits(n: int):
	return list(bin(n)).count('1')

def flush():
	sys.stdout.flush()

def parr(arr):
	print(*arr, sep=' ')

def gcd(a, b):
	while b:
		if b % a == 0:
			break
		tmp = a
		a = b % a
		b = tmp
	return a

def ext_gcd(a: int, b: int):
	if b == 0:
		return [a, [1, 0]]
	res = ext_gcd(b, a % b)
	g = res[0]
	if g != 1:
		return False
	x1 = res[1][0]
	y1 = res[1][1]
	x = y1
	y = x1 - y1 * (a // b)
	return [g, [x, y]]

def get_set(a):
	res = {}
	for x in a:
		if x in res:
			res[x] += 1
		else:
			res[x] = 1
	return res
fact = {0: 1}

def factorial(n):
	if dynamic_factorial:
		if n not in fact:
			fact[n] = factorial(n - 1) * n
		return fact[n]
	else:
		res = 1
		while n > 0:
			res = res * n % mod
			n -= 1
		return res

def sum_of(a):
	res = 0
	for x in a:
		res = (res + x) % mod
	return res

def prod_of(a):
	res = 1
	for x in a:
		res = res * x % mod
	return res

def test():
	n = get()[0]
	a = sorted(get())
	i = 0
	j = n - 1
	best = []
	while i < 5 and j >= n - 5 and (i <= j):
		if i == j:
			best.append(a[i])
		else:
			best.append(a[i])
			best.append(a[j])
		i += 1
		j -= 1
	n = len(best)
	ans = a[0] * a[1] * a[2] * a[3] * a[4]
	i = 0
	while i < n:
		j = i + 1
		while j < n:
			k = j + 1
			while k < n:
				l = k + 1
				while l < n:
					m = l + 1
					while m < n:
						ans = max(ans, best[i] * best[j] * best[k] * best[l] * best[m])
						m += 1
					l += 1
				k += 1
			j += 1
		i += 1
	print(ans)
main(cases)


def prod(arr):
	p = 1
	for i in arr:
		p *= i
	return p
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	maxx = prod(arr[:5])
	maxx = max(maxx, prod(arr[:4] + arr[-1:]))
	maxx = max(maxx, prod(arr[:3] + arr[-2:]))
	maxx = max(maxx, prod(arr[:2] + arr[-3:]))
	maxx = max(maxx, prod(arr[:1] + arr[-4:]))
	maxx = max(maxx, prod(arr[:0] + arr[-5:]))
	print(maxx)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	total = 1
	if n == 5:
		for i in arr:
			total *= i
		print(total)
		continue
	arr.sort()
	if arr[n - 1] <= 0:
		for i in range(n - 1, n - 6, -1):
			total *= arr[i]
		print(total)
		continue
	i = 0
	j = n - 1
	total *= arr[j]
	j -= 1
	left = arr[i] * arr[i + 1]
	right = arr[j] * arr[j - 1]
	if left > right:
		total *= left
		i += 2
	else:
		total *= right
		j -= 2
	left = arr[i] * arr[i + 1]
	right = arr[j] * arr[j - 1]
	if left > right:
		total *= left
	else:
		total *= right
	print(total)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
from collections import Counter, defaultdict, deque

def int1():
	return int(input())

def map1():
	return map(int, input().split())

def list1():
	return list(map(int, input().split()))
mod = pow(10, 9) + 7

def solve():
	n = int1()
	l1 = list1()
	l1.sort()
	v = max(l1[-1] * l1[-2] * l1[-3] * l1[-4] * l1[-5], l1[-1] * l1[0] * l1[1] * l1[2] * l1[3], l1[-2] * l1[0] * l1[1] * l1[2] * l1[-1])
	v1 = max(l1[-1] * l1[0] * l1[1] * l1[-2] * l1[-3], l1[-4] * l1[0] * l1[-1] * l1[-2] * l1[-3])
	print(max(v, v1))
for _ in range(int(input())):
	solve()


import sys
z = sys.stdin.readline
for _ in range(int(z())):
	n = int(z())
	a = sorted(map(int, z().split()))
	r = 1
	exec(2 * 'if a[-1]>=0 and a[0]*a[1]>=a[-4]*a[-5]:a=a[2:]+[1,a[0]*a[1]]\n')
	exec(5 * 'r*=a.pop();')
	print(r)


t = int(input())
results = []
for i in range(t):
	n = int(input())
	vals = input().split()
	a = [int(val) for val in vals]
	if n == 5:
		results.append(a[0] * a[1] * a[2] * a[3] * a[4])
	else:
		a.sort()
		prod1 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
		prod2 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
		prod3 = a[0] * a[1] * a[2] * a[3] * a[-1]
		results.append(max(prod1, prod2, prod3))
for result in results:
	print(result)


for i in range(int(input())):
	n = int(input())
	ar = [int(i) for i in input().split()]
	ar.sort()
	print(max(ar[-1] * ar[-2] * ar[-3] * ar[1] * ar[0], ar[0] * ar[1] * ar[2] * ar[3] * ar[-1], ar[-1] * ar[-2] * ar[-3] * ar[-4] * ar[-5]))


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math
import random
J = 998244353
from collections import deque

def calc(n, A):
	pos = []
	neg = []
	z = 0
	for i in range(n):
		if A[i] > 0:
			pos.append(A[i])
		elif A[i] < 0:
			neg.append(A[i])
		else:
			z += 1
	pos.sort(reverse=True)
	neg.sort()
	ans = -10 ** 100
	if len(pos) >= 5:
		ans = 1
		for i in range(5):
			ans *= pos[i]
	if len(pos) >= 4 and len(neg) >= 1:
		d = 1
		d = pos[-1] * pos[-2] * pos[-3] * pos[-4] * neg[-1]
		ans = max(ans, d)
	if len(pos) >= 3 and len(neg) >= 2:
		d = 1
		d = pos[0] * pos[1] * pos[2] * neg[0] * neg[1]
		ans = max(ans, d)
	if len(pos) >= 2 and len(neg) >= 3:
		d = 1
		d = pos[-1] * pos[-2] * neg[-1] * neg[-2] * neg[-3]
		ans = max(ans, d)
	if len(pos) >= 1 and len(neg) >= 4:
		d = 1
		d = pos[0] * neg[0] * neg[1] * neg[2] * neg[3]
		ans = max(ans, d)
	if len(neg) >= 5:
		d = 1
		d = neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5]
		ans = max(ans, d)
	if z > 0:
		return max(ans, 0)
	else:
		return ans
for _ in range(int(input())):
	n = int(input())
	A = INPUT()
	print(calc(n, A))


from collections import deque
from math import *
t = int(input())
for _ in range(t):
	n = int(input())
	arr = sorted([int(p) for p in input().split()])
	s1 = arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3]
	s2 = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	s3 = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	s4 = arr[0] * arr[-1] * arr[-2] * arr[-3] * arr[-4]
	s5 = arr[0] * arr[1] * arr[2] * arr[-1] * arr[-2]
	s6 = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	print(max(s1, s2, s3, s4, s5, s6))


import heapq
inputed = []
count = int(input())
linesPer = 2
for i in range(count * linesPer):
	inputed.append(input())
t = 0
for i in range(count):
	try:
		inputed[t + 1] = inputed[t + 1].split(' ')
		inputed[t + 1] = [int(x) for x in inputed[t + 1]]
		neg = [-x for x in inputed[t + 1]]
		heapq.heapify(inputed[t + 1])
		heapq.heapify(neg)
		heap = inputed[t + 1]
		topFive = []
		botFive = []
		for i in range(5):
			topFive.append(-heapq.heappop(neg))
			botFive.append(heapq.heappop(heap))
		mult = 1
		for num in topFive:
			mult *= num
		op1 = mult
		op2 = topFive[0] * botFive[0] * botFive[1] * botFive[2] * botFive[3]
		op3 = topFive[0] * topFive[1] * topFive[2] * botFive[0] * botFive[1]
		print(max(op1, op2, op3))
	except:
		print(0)
	t += linesPer


import sys
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	pos = 0
	neg = 0
	p = []
	ne = []
	for j in range(n):
		if a[j] < 0:
			ne.append(a[j])
			neg = neg + 1
		else:
			p.append(a[j])
			pos = pos + 1
	ne.sort()
	p.sort()
	g = []
	c = 0
	for j in range(6):
		if j % 2 == 0:
			if pos >= j and neg >= 5 - j:
				l = 1
				for k in range(j):
					l = l * p[k]
				for k in range(5 - j):
					l = l * ne[neg - k - 1]
				g.append(l)
				c = c + 1
		if j % 2 == 1:
			if pos >= j and neg >= 5 - j:
				l = 1
				for k in range(j):
					l = l * p[pos - k - 1]
				for k in range(5 - j):
					l = l * ne[k]
				g.append(l)
				c = c + 1
	print(max(g))


from sys import stdin, stdout
from math import gcd, sqrt, inf
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
M = inf
for _ in range(I()):
	n = I()
	N = []
	P = []
	(*a,) = R()
	for i in a:
		if i < 0:
			N += (i,)
		else:
			P += (i,)
	ln1 = len(N)
	ln2 = len(P)
	if ln2 == 0 or ln1 + ln2 - ln1 % 2 < 5:
		sm = 1
		N.sort()
		P.sort(reverse=True)
		for i in range(5):
			if not P:
				sm *= N.pop()
			elif not N:
				sm *= P.pop()
			elif abs(N[-1]) < P[-1]:
				sm *= N.pop()
			else:
				sm *= P.pop()
		print(sm)
	else:
		a.sort(reverse=True, key=lambda x: abs(x))
		p = a[:5]
		a = a[5:]
		sm = 1
		for i in p:
			sm *= i
		ans = sm
		if sum([1 if i < 0 else 0 for i in p]) % 2:
			for i in range(4, -1, -1):
				sm = 1
				for d in range(5):
					if d != i:
						sm *= p[d]
				for j in a:
					ans = max(ans, sm * j)
		print(ans)


from fractions import Fraction
import bisect
import os
import io
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = 1
t = iinput()
for _ in range(t):
	n = iinput()
	a = rlinput()
	a.sort()
	val1 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	val2 = a[0] * a[1] * a[2] * a[3] * a[-1]
	val3 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	print(max(val1, val2, val3))


for _ in range(int(input())):
	tam = int(input())
	numeros = list(map(int, input().split()))
	zeros = 0
	hay0 = False
	numPos = []
	numNeg = []
	for i in range(tam):
		if numeros[i] < 0:
			numNeg.append(numeros[i])
		elif numeros[i] == 0:
			hay0 = True
			zeros += 1
		else:
			numPos.append(numeros[i])
	if len(numPos) + len(numNeg) < 5:
		print(0)
		continue
	aux = len(numeros)
	ashuda = 0
	while zeros > 0 and aux > 5 and (ashuda < len(numeros)):
		if numeros[ashuda] == 0:
			numeros.pop(ashuda)
			aux = aux - 1
			zeros = zeros - 1
		ashuda += 1
	if len(numeros) == 5:
		result = 1
		for i in range(5):
			result = result * numeros[i]
		if hay0 and result < 0:
			print(0)
			continue
		print(result)
		continue
	numPos.sort()
	numNeg.sort()
	numerosFinal = []
	numPos.reverse()
	posibles = []
	if len(numPos) >= 1 and len(numNeg) >= 4:
		numerosFinal.append(numPos[0])
		numerosFinal.append(numNeg[0])
		numerosFinal.append(numNeg[1])
		numerosFinal.append(numNeg[2])
		numerosFinal.append(numNeg[3])
		result = 1
		for i in range(5):
			result = result * numerosFinal[i]
		posibles.append(result)
		numerosFinal.clear()
	if len(numNeg) >= 1 and len(numPos) >= 4:
		numerosFinal.append(numNeg[-1])
		numerosFinal.append(numPos[0])
		numerosFinal.append(numPos[1])
		numerosFinal.append(numPos[2])
		numerosFinal.append(numPos[3])
		result = 1
		for i in range(5):
			result = result * numerosFinal[i]
		posibles.append(result)
		numerosFinal.clear()
	if len(numNeg) >= 2 and len(numPos) >= 3:
		numerosFinal.append(numPos[0])
		numerosFinal.append(numNeg[0])
		numerosFinal.append(numNeg[1])
		numerosFinal.append(numPos[1])
		numerosFinal.append(numPos[2])
		result = 1
		for i in range(5):
			result = result * numerosFinal[i]
		posibles.append(result)
		numerosFinal.clear()
	if len(numPos) >= 2 and len(numNeg) >= 3:
		numerosFinal.append(numNeg[-1])
		numerosFinal.append(numPos[0])
		numerosFinal.append(numPos[1])
		numerosFinal.append(numNeg[-2])
		numerosFinal.append(numNeg[-3])
		result = 1
		for i in range(5):
			result = result * numerosFinal[i]
		posibles.append(result)
		numerosFinal.clear()
	if len(numPos) >= 5:
		numerosFinal.append(numPos[0])
		numerosFinal.append(numPos[1])
		numerosFinal.append(numPos[2])
		numerosFinal.append(numPos[3])
		numerosFinal.append(numPos[4])
		result = 1
		for i in range(5):
			result = result * numerosFinal[i]
		posibles.append(result)
		numerosFinal.clear()
	if len(numNeg) >= 5:
		numerosFinal.append(numNeg[-1])
		numerosFinal.append(numNeg[-2])
		numerosFinal.append(numNeg[-3])
		numerosFinal.append(numNeg[-4])
		numerosFinal.append(numNeg[-5])
		result = 1
		for i in range(5):
			result = result * numerosFinal[i]
		posibles.append(result)
		numerosFinal.clear()
	posibles.sort()
	if hay0 and posibles[-1] < 0:
		print(0)
		continue
	print(posibles[-1])


def answer(n):
	q = list(map(int, input().split()))
	q.sort()
	s = []
	flag = 0
	for i in q:
		if i != 0:
			s.append(i)
		else:
			flag = 1
	if len(s) < 5:
		print(0)
		return
	ans = 1
	n = len(s)
	if s[-1] < 0:
		if flag:
			print(0)
			return
		num = n - 1
		for i in range(5):
			ans *= s[num]
			num -= 1
		print(ans)
		return
	ans = max(s[n - 1] * s[n - 2] * s[n - 3] * s[n - 4] * s[n - 5], s[n - 1] * s[0] * s[1] * s[2] * s[3], s[n - 1] * s[n - 2] * s[n - 3] * s[0] * s[1])
	if ans < 0 and flag:
		print(0)
		return
	print(ans)
for _ in range(int(input())):
	answer(int(input()))


t = int(input())
for ex in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a_p = list()
	a_n = list()
	a.sort()
	if a[0] < 0 and a[1] < 0:
		ans1 = a[0] * a[1] * a[n - 1] * a[n - 2] * a[n - 3]
	else:
		ans1 = -1 * pow(10, 20)
	if a[0] < 0 and a[1] < 0 and (a[2] < 0) and (a[3] < 0):
		ans2 = a[0] * a[1] * a[n - 1] * a[2] * a[3]
	else:
		ans2 = -1 * pow(10, 20)
	ans3 = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5]
	print(max(ans1, ans2, ans3))


def read_line():
	return list(map(int, input().split()))

def pr(l):
	a = 1
	for x in l:
		a *= x
	return a
T = int(input())
for _ in range(T):
	n = int(input())
	l = list(sorted(read_line()))
	l2 = list(reversed(l))
	m = None
	for i in range(6):
		j = 5 - i
		a = l[:i]
		b = l2[:j]
		p = pr(a) * pr(b)
		if m == None or p > m:
			m = p
	print(m)


a = int(input())
for i in range(a):
	b = int(input())
	c = [int(x) for x in input().split()]
	c.sort()
	c = c[::-1]
	if c[0] <= 0 or c[b - 1] >= 0:
		x = c[0] * c[1] * c[2] * c[3] * c[4]
	else:
		x1 = c[b - 1] * c[b - 2] * c[0] * c[1] * c[2]
		x2 = c[b - 1] * c[b - 2] * c[b - 3] * c[b - 4] * c[0]
		x3 = c[0] * c[1] * c[2] * c[3] * c[4]
		x = max(x1, x2, x3)
	print(x)


import math
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	maxa = [[None] * 6 for i in range(0, n + 1)]
	mina = [[None] * 6 for i in range(0, n + 1)]
	maxa[0][1] = a[0]
	mina[0][1] = a[0]
	for i in range(1, n):
		for j in range(1, 6):
			if maxa[i - 1][j - 1] is not None:
				val1 = maxa[i - 1][j - 1] * a[i]
				val2 = mina[i - 1][j - 1] * a[i]
				maxa[i][j] = max(val1, val2)
				mina[i][j] = min(val1, val2)
			elif j == 1:
				maxa[i][j] = a[i]
				mina[i][j] = a[i]
			if maxa[i - 1][j] is not None:
				maxa[i][j] = max(maxa[i][j], maxa[i - 1][j])
				mina[i][j] = min(mina[i][j], mina[i - 1][j])
	print(maxa[n - 1][5])
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	v = list(map(int, input().split()))
	pro = 1
	v.sort()
	ans1 = v[n - 1] * v[n - 2] * v[n - 3] * v[n - 4] * v[n - 5]
	ans2 = v[0] * v[1] * v[n - 1] * v[n - 2] * v[n - 3]
	ans3 = v[0] * v[1] * v[2] * v[3] * v[n - 1]
	print(max(ans1, ans2, ans3))


import sys
input = sys.stdin.readline
from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = float('-inf')
	cur = 1
	for i in range(n - 1, n - 6, -1):
		cur *= a[i]
	ans = max(ans, cur)
	cur = 1
	for i in range(n - 1, n - 4, -1):
		cur *= a[i]
	cur *= a[0] * a[1]
	ans = max(ans, cur)
	cur = 1
	for i in range(4):
		cur *= a[i]
	cur *= a[-1]
	ans = max(ans, cur)
	print(ans)


import sys
from itertools import accumulate
from math import log2

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	K = 5
	A1 = []
	A2 = []
	B1 = []
	B2 = []
	zero = 0
	for a in A:
		if a > 0:
			A1.append(a)
			B1.append(log2(a))
		elif a < 0:
			A2.append(-a)
			B2.append(log2(-a))
		else:
			zero += 1
	A1.sort()
	A2.sort()
	B1.sort()
	B2.sort()
	acc1 = [0] + list(accumulate(B1))
	accrev1 = [0] + list(accumulate(B1[::-1]))
	acc2 = [0] + list(accumulate(B2))
	accrev2 = [0] + list(accumulate(B2[::-1]))
	mx = -INF
	mn = INF
	idx1 = (-1, -1)
	idx2 = (-1, -1)
	for i in range(K + 1):
		j = K - i
		if len(B1) < i or len(B2) < j:
			continue
		if j % 2 == 0:
			sm = accrev1[i] + accrev2[j]
			if sm > mx:
				mx = sm
				idx1 = (i, j)
		else:
			sm = acc1[i] + acc2[j]
			if sm < mn:
				mn = sm
				idx2 = (i, j)
	if mx != -INF:
		ans = 1
		(n, m) = idx1
		A1.reverse()
		A2.reverse()
		for i in range(n):
			ans *= A1[i]
		for i in range(m):
			ans *= -A2[i]
		print(ans)
	elif zero:
		print(0)
	else:
		ans = 1
		(n, m) = idx2
		for i in range(n):
			ans *= A1[i]
		for i in range(m):
			ans *= -A2[i]
		print(ans)


from functools import reduce
import operator

def calc_product(integers):
	return reduce(operator.mul, integers, 1)
num_cases = int(input())
for i in range(num_cases):
	case_len = input()
	case_str = input()
	integers = list(map(int, case_str.split(' ')))
	if len(integers) == 5:
		print(calc_product(integers))
		continue
	positives = list(filter(lambda x: x >= 0, integers))
	negatives = list(filter(lambda x: x < 0, integers))
	positives_sorted = sorted(positives, reverse=True)
	negatives_sorted = sorted(negatives)
	results = []
	if len(positives_sorted) >= 5:
		results.append(calc_product(positives_sorted[:5]))
	if len(negatives_sorted) >= 2 and len(positives_sorted) >= 3:
		results.append(calc_product(positives_sorted[:3] + negatives_sorted[:2]))
	if len(negatives_sorted) >= 4 and len(positives_sorted) >= 1:
		results.append(calc_product(positives_sorted[:1] + negatives_sorted[:4]))
	if len(negatives_sorted) >= 1 and len(positives_sorted) >= 4:
		results.append(calc_product(positives_sorted[-4:] + negatives_sorted[-1:]))
	if len(negatives_sorted) >= 3 and len(positives_sorted) >= 2:
		results.append(calc_product(positives_sorted[-2:] + negatives_sorted[-3:]))
	if len(negatives_sorted) >= 5:
		results.append(calc_product(negatives_sorted[-5:]))
	print(max(results))


import math
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	print(max(arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5], arr[0] * arr[1] * arr[2] * arr[3] * arr[-1], arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3]))


def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
import collections as c

def solve():
	N = getInt()
	A = getInts()
	A.sort()
	candidates = []
	candidates.append(A[-1] * A[-2] * A[-3] * A[-4] * A[-5])
	candidates.append(A[-1] * A[-2] * A[-3] * A[0] * A[1])
	candidates.append(A[-1] * A[0] * A[1] * A[2] * A[3])
	if 0 in A:
		candidates.append(0)
	return max(candidates)
T = getInt()
for t in range(T):
	ans = solve()
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m1 = -10000
	m2 = -10000
	m3 = -10000
	m4 = -10000
	m5 = -10000
	mi1 = 10000
	mi2 = 10000
	mi3 = 10000
	mi4 = 10000
	mi5 = 10000
	for i in a:
		if i >= m1:
			(m1, m2, m3, m4, m5) = (i, m1, m2, m3, m4)
		elif i >= m2:
			(m2, m3, m4, m5) = (i, m2, m3, m4)
		elif i >= m3:
			(m3, m4, m5) = (i, m3, m4)
		elif i >= m4:
			(m4, m5) = (i, m4)
		elif i >= m5:
			m5 = i
		if i <= mi1:
			(mi1, mi2, mi3, mi4, mi5) = (i, mi1, mi2, mi3, mi4)
		elif i <= mi2:
			(mi2, mi3, mi4, mi5) = (i, mi2, mi3, mi4)
		elif i <= mi3:
			(mi3, mi4, mi5) = (i, mi3, mi4)
		elif i <= mi4:
			(mi4, mi5) = (i, mi4)
		elif i <= mi5:
			mi5 = i
	a = m1 * m2 * m3 * m4 * m5
	b = m1 * mi1 * mi2 * mi3 * mi4
	c = m1 * m2 * m3 * mi1 * mi2
	print(max(a, b, c))


def maxProductSubarrayOfSizeK(A, n, k):
	A.sort()
	product = 1
	if A[n - 1] == 0 and k & 1:
		return 0
	if A[n - 1] <= 0 and k & 1:
		for i in range(n - 1, n - k + 1, -1):
			product *= A[i]
		return product
	i = 0
	j = n - 1
	if k & 1:
		product *= A[j]
		j -= 1
		k -= 1
	k >>= 1
	for itr in range(k):
		left_product = A[i] * A[i + 1]
		right_product = A[j] * A[j - 1]
		if left_product > right_product:
			product *= left_product
			i += 2
		else:
			product *= right_product
			j -= 2
	return product
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	p = 0
	for i in A:
		if i >= 0:
			p += 1
			break
	if p == 0:
		A.sort(reverse=True)
		B = A[0:5]
		prod = 1
		for i in B:
			prod *= i
		print(prod)
	else:
		print(maxProductSubarrayOfSizeK(A, n, 5))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	pos = []
	neg = []
	zer = []
	for i in ar:
		if i > 0:
			pos.append(i)
		elif i < 0:
			neg.append(i)
		else:
			zer.append(i)
	if len(pos) == 0:
		if len(zer) != 0:
			ans = 0
		else:
			ar.sort(key=lambda x: abs(x))
			ans = 1
			for i in range(5):
				ans *= ar[i]
	else:
		ans = max(pos)
		pos.remove(ans)
		le1 = len(pos)
		le2 = len(neg)
		le3 = len(zer)
		a1 = []
		if le1 >= 2:
			pos.sort(reverse=True)
			for i in range(1, le1, 2):
				a1.append(pos[i] * pos[i - 1])
		if le2 >= 2:
			neg.sort()
			for i in range(1, le2, 2):
				a1.append(neg[i] * neg[i - 1])
		if len(a1) >= 2:
			a1.sort(reverse=True)
			for i in range(2):
				ans *= a1[i]
		elif le3 != 0:
			ans = 0
		else:
			ar.sort(key=lambda x: abs(x))
			ans = 1
			for i in range(5):
				ans *= ar[i]
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	arr = sorted(arr)
	least_two = arr[0] * arr[1]
	least_four = arr[0] * arr[1] * arr[2] * arr[3]
	top_1 = arr[n - 1]
	top_3 = arr[n - 1] * arr[n - 2] * arr[n - 3]
	top_5 = arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5]
	ans = max(top_5, top_3 * least_two, top_1 * least_four)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	if n == 5:
		tmp = 1
		for i in lst:
			tmp *= i
		print(int(tmp))
		continue
	z = []
	f = []
	for i in lst:
		if i >= 0:
			z.append(i)
		else:
			f.append(i)
	z.sort(reverse=True)
	f.sort()
	ans = -69540876599103
	if len(z) >= 5:
		tmp = 1
		for i in range(0, 5):
			tmp *= z[i]
		ans = max(ans, tmp)
	if len(f) >= 4 and len(z) >= 1:
		tmp = 1
		for i in range(0, 4):
			tmp *= f[i]
		tmp *= z[0]
		ans = max(ans, tmp)
	if len(f) >= 2 and len(z) >= 3:
		tmp = 1
		for i in range(0, 2):
			tmp *= f[i]
		for i in range(0, 3):
			tmp *= z[i]
		ans = max(ans, tmp)
	if len(f) >= 5 and len(z) == 0:
		tmp = 1
		for i in range(-5, 0):
			tmp *= f[i]
		ans = tmp
	print(int(ans))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cp = []
	cn = []
	for i in range(n):
		if a[i] < 0:
			cn.append(a[i])
		else:
			cp.append(a[i])
	cp.sort()
	cp.reverse()
	cn.sort()
	x = cp[:5] + cn[:5]
	max = -1000000000000000000000000000
	for i in range(len(x) - 4):
		for j in range(i + 1, len(x) - 3):
			for k in range(j + 1, len(x) - 2):
				for l in range(k + 1, len(x) - 1):
					for m in range(l + 1, len(x)):
						if x[i] * x[j] * x[k] * x[l] * x[m] > max:
							max = x[i] * x[j] * x[k] * x[l] * x[m]
	cn.reverse()
	x = cp[:5] + cn[:5]
	for i in range(len(x) - 4):
		for j in range(i + 1, len(x) - 3):
			for k in range(j + 1, len(x) - 2):
				for l in range(k + 1, len(x) - 1):
					for m in range(l + 1, len(x)):
						if x[i] * x[j] * x[k] * x[l] * x[m] > max:
							max = x[i] * x[j] * x[k] * x[l] * x[m]
	print(max)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def ceil(x, y=1):
	return int(-(-x // y))
import math
from collections import defaultdict
for _ in range(ri()):
	n = ri()
	v = ria()
	v.sort()
	for i in range(n):
		ans = max(v[0] * v[1] * v[n - 1] * v[n - 2] * v[n - 3], max(v[0] * v[1] * v[n - 1] * v[2] * v[3], v[n - 1] * v[n - 2] * v[n - 3] * v[n - 4] * v[n - 5]))
	print(ans)


from functools import reduce
n = int(input())
for i in range(n):
	qtd = int(input())
	valores = list(map(int, input().split(' ')))
	ordenados = sorted(valores, key=abs, reverse=True)
	negativos_primeiros = [x for x in ordenados[:5] if x < 0]
	positivos_primeiros = [x for x in ordenados[:5] if x >= 0]
	positivos = [x for x in ordenados[5:] if x >= 0]
	negativos = [x for x in ordenados[5:] if x < 0]
	produto = reduce(lambda x, y: x * y, ordenados[:5])
	if produto >= 0:
		print(produto)
	else:
		if positivos:
			vai_sair = max(negativos_primeiros)
			vai_entrar = positivos[0]
			nova_lista = ordenados[:5]
			nova_lista.remove(vai_sair)
			nova_lista.append(vai_entrar)
			produto_com_positivo = reduce(lambda x, y: x * y, nova_lista)
			if produto_com_positivo > produto:
				produto = produto_com_positivo
		if negativos:
			if positivos_primeiros:
				vai_sair = min(positivos_primeiros)
				vai_entrar = negativos[0]
				nova_lista = ordenados[:5]
				nova_lista.remove(vai_sair)
				nova_lista.append(vai_entrar)
				produto_com_negativo = reduce(lambda x, y: x * y, nova_lista)
				if produto_com_negativo > produto:
					produto = produto_com_negativo
			else:
				negativos.extend(negativos_primeiros)
				negativos.sort(reverse=True)
				produto_com_negativo = reduce(lambda x, y: x * y, negativos[:5])
				if produto_com_negativo > produto:
					produto = produto_com_negativo
		print(produto)


from sys import stdin, stdout

def input():
	return stdin.readline().strip()

def ans_slow(A):
	A = sorted(A)
	neg = [a for a in A if a < 0]
	pos = [a for a in A if a > 0]
	zer = [a for a in A if a == 0]
	A = neg + pos + zer
	ret = float('-inf')
	for i in range(0, len(A)):
		for j in range(i + 1, len(A)):
			for k in range(j + 1, len(A)):
				for l in range(k + 1, len(A)):
					for t in range(l + 1, len(A)):
						ret = max(ret, A[i] * A[j] * A[k] * A[l] * A[t])
	return ret

def prod(A):
	ret = 1
	for a in A:
		ret *= a
	return ret

def ans(A):
	A = sorted(A)
	neg = [a for a in A if a < 0]
	pos = [a for a in A if a > 0]
	zer = [a for a in A if a == 0]
	if len(pos) == 0 and len(zer) == 0:
		return prod(neg[::-1][0:5])
	if len(zer) >= 5:
		zer = [0] * 5
	if len(neg) >= 5:
		neg = neg[:5]
	if len(pos) >= 5:
		pos = pos[len(pos) - 5:]
	assert len(zer) <= 5
	assert len(pos) <= 5
	assert len(neg) <= 5
	A = neg + pos + zer
	ret = float('-inf')
	for i in range(0, len(A)):
		for j in range(i + 1, len(A)):
			for k in range(j + 1, len(A)):
				for l in range(k + 1, len(A)):
					for t in range(l + 1, len(A)):
						ret = max(ret, A[i] * A[j] * A[k] * A[l] * A[t])
	return ret
if False:
	import random
	for _ in range(10000):
		test_case = [random.randint(-3, 3) for _ in range(12)]
		if ans(test_case) != ans_slow(test_case):
			print(test_case)
else:
	T = int(input())
	for t in range(T):
		input()
		A = list(map(int, input().split()))
		print(ans(A))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def fil(val):
	return abs(val)

def solve(l, n):
	l.sort()
	a = l[-5] * l[-4] * l[-3] * l[-2] * l[-1]
	b = l[0] * l[1] * l[-3] * l[-2] * l[-1]
	c = l[0] * l[1] * l[2] * l[3] * l[-1]
	return max(a, b, c)
t = inp()
while t > 0:
	n = inp()
	arr = inlt()
	print(solve(arr, n))
	t -= 1


from copy import deepcopy
t = int(input())
for T in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	amin = []
	amax = []
	b = deepcopy(a)
	for i in range(5):
		temp = max(a)
		amax.append(temp)
		a.remove(temp)
		temp = min(b)
		amin.append(temp)
		b.remove(temp)
	amax.sort()
	amin.sort()
	if amin == amax:
		print(amax[0] * amax[1] * amax[2] * amax[3] * amax[4])
	else:
		one = amin[0] * amin[1] * amin[2] * amin[3] * amax[4]
		two = amin[0] * amin[1] * amax[4] * amax[3] * amax[2]
		three = amax[4] * amax[3] * amax[2] * amax[1] * amax[0]
		print(max(one, two, three))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	a = 1
	if n == 5:
		for i in arr:
			a *= i
		print(a)
	elif max(arr) <= 0:
		if max(arr) == 0:
			a = 0
		arr.sort(reverse=True)
		for i in range(5):
			a *= arr[i]
		print(a)
	else:
		n = []
		p = []
		arr.sort(reverse=True)
		for i in arr:
			if i >= 0:
				p.append(i)
			else:
				n.append(i)
		n.sort()
		p.sort(reverse=True)
		m1 = 0
		m2 = 0
		m3 = 0
		if len(n) > 1 and len(p) > 2:
			m1 = n[0] * n[1] * p[0] * p[1] * p[2]
		if len(n) > 3 and len(p) > 0:
			m2 = n[0] * n[1] * p[0] * n[3] * n[2]
		if len(p) > 4:
			m3 = p[4] * p[1] * p[0] * p[2] * p[3]
		print(max(m1, m2, m3))


from functools import reduce
from operator import mul

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	n = inp()
	l = inlt()
	l.sort()
	p1 = reduce(mul, l[:2] + l[-3:])
	p2 = reduce(mul, l[:4] + l[-1:])
	p3 = reduce(mul, l[-5:])
	print(max([p1, p2, p3]))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	pos = l[-1]
	neg = l[0] * l[1] * l[2] * l[3]
	ans = pos * neg
	pos = l[-1] * l[-2] * l[-3]
	neg = l[0] * l[1]
	ans = max(ans, pos * neg)
	pos = l[-1] * l[-2] * l[-3] * l[-4] * l[-5]
	ans = max(ans, pos)
	if 0 in l:
		ans = max(ans, 0)
	print(ans)


import collections

def solution(n, a):
	a.sort()
	x1 = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5]
	x2 = a[n - 1] * a[n - 2] * a[n - 3] * a[0] * a[1]
	x3 = a[n - 1] * a[0] * a[1] * a[2] * a[3]
	return max(x1, x2, x3)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	print(solution(n, a))


import os, sys
from io import BytesIO, IOBase
from math import inf

def main():
	for _ in range(int(input())):
		n = int(input())
		(pos, neg) = ([], [])
		for i in map(int, input().split()):
			if i > 0:
				pos.append(i)
			else:
				neg.append(i)
		(pos.sort(reverse=1), neg.sort(key=lambda x: abs(x), reverse=1))
		ans = -inf
		for i in range(min(6, len(pos) + 1)):
			if 5 - i > len(neg):
				continue
			ans1 = 1
			for j in range(i):
				ans1 *= pos[j]
			if (5 - i) % 2:
				for j in range(5 - i):
					ans1 *= neg[-j - 1]
			else:
				for j in range(5 - i):
					ans1 *= neg[j]
			ans = max(ans, ans1)
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
input = sys.stdin.readline

def multi(myList):
	result = 1
	for x in myList:
		result = result * x
	return result
from collections import Counter
from math import sqrt, ceil, floor
for t in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr = sorted(arr)
	if n == 5:
		print(multi(arr))
	else:
		ans1 = multi(arr[:5])
		ans2 = multi(arr[-5:])
		ans3 = multi(arr[:4] + [arr[-1]])
		ans4 = multi(arr[:2] + arr[-3:])
		print(max(ans4, ans3, ans2, ans1))


def my_func(d):
	p_max = p1 = p2 = p3 = p4 = d[0] * d[1] * d[2] * d[3] * d[4]
	pol = []
	otr = []
	kol_nul = 0
	for i in d:
		if i > 0:
			pol.append(i)
		elif i < 0:
			otr.append(i)
		else:
			kol_nul += 1
	pol_sort = sorted(pol, reverse=True)
	otr_sort = sorted(otr)
	if len(pol) >= 5:
		p1 = pol_sort[0] * pol_sort[1] * pol_sort[2] * pol_sort[3] * pol_sort[4]
	if len(pol) >= 3 and len(otr) >= 2:
		p2 = pol_sort[0] * pol_sort[1] * pol_sort[2] * otr_sort[0] * otr_sort[1]
	if len(pol) >= 1 and len(otr) >= 4:
		p3 = pol_sort[0] * otr_sort[0] * otr_sort[1] * otr_sort[2] * otr_sort[3]
	if len(pol) == 0 and len(otr) >= 5:
		p4 = otr_sort[-1] * otr_sort[-2] * otr_sort[-3] * otr_sort[-4] * otr_sort[-5]
	p_max = max(p_max, p1, p2, p3, p4)
	if kol_nul > 0:
		p_max = max(p_max, 0)
	return p_max
a = []
k = int(input())
for i in range(k):
	int(input())
	d = list(map(int, input().split()))
	a.append(my_func(d))
for i in range(k):
	print(a[i])


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	p = max(l[-1] * l[-2] * l[-3] * l[-4] * l[-5], l[-1] * l[-2] * l[-3] * l[0] * l[1], l[-1] * l[0] * l[1] * l[2] * l[3])
	p = max(p, l[-1] * l[-2] * l[-3] * l[-4] * l[0], l[-1] * l[-2] * l[0] * l[1] * l[2], l[1] * l[0] * l[2] * l[3] * l[4])
	print(p)


t = int(input())
for tc in range(t):
	n = int(input())
	line = input().split()
	arr = []
	indices = []
	for i in range(n):
		arr.append(int(line[i]))
	arr.sort()
	maxpro = float('-inf')
	for i in range(5):
		a = (n - 1 + i) % n
		b = (n - 2 + i) % n
		c = (n - 3 + i) % n
		d = (n - 4 + i) % n
		e = (n - 5 + i) % n
		prod = arr[a] * arr[b] * arr[c] * arr[d] * arr[e]
		if prod > maxpro:
			maxpro = prod
	print(maxpro)


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve(lst):
	console('----- solving ------')
	maxres = lst[0] * lst[1] * lst[2] * lst[3] * lst[4]
	if 0 in lst:
		maxres = max(maxres, 0)
	positives = sorted([a for a in lst if a >= 0])[::-1]
	negatives = sorted([a for a in lst if a < 0])
	if len(positives) >= 5 and len(negatives) >= 0:
		maxres = max(maxres, positives[0] * positives[1] * positives[2] * positives[3] * positives[4])
	if len(positives) >= 3 and len(negatives) >= 2:
		maxres = max(maxres, positives[0] * positives[1] * positives[2] * negatives[0] * negatives[1])
	if len(positives) >= 1 and len(negatives) >= 4:
		maxres = max(maxres, positives[0] * negatives[0] * negatives[1] * negatives[2] * negatives[3])
	if len(negatives) >= 5:
		maxres = max(maxres, negatives[-1] * negatives[-2] * negatives[-3] * negatives[-4] * negatives[-5])
	return maxres

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	k = int(input())
	lst = list(map(int, input().split()))
	res = solve(lst)
	print(res)


def multiplicar(lista_numeros):
	multiplicacion = lista_numeros[0]
	for i in range(1, len(lista_numeros)):
		multiplicacion *= lista_numeros[i]
	return multiplicacion

def multiplicacion2(lista_numeros):
	lista_numeros.sort()
	positivos5 = lista_numeros[-5:]
	positivos3 = lista_numeros[-3:] + lista_numeros[0:2]
	positivos1 = lista_numeros[-1:] + lista_numeros[0:4]
	mult5 = multiplicar(positivos5)
	mult3 = multiplicar(positivos3)
	mult1 = multiplicar(positivos1)
	return max(mult5, max(mult3, mult1))
tests = int(input())
for i in range(tests):
	indices = int(input())
	lista_numeros = list(map(int, input().split()))
	if indices == 5:
		print(multiplicar(lista_numeros))
	else:
		print(multiplicacion2(lista_numeros))


def ans_if_list(ans):
	if isinstance(ans, str):
		return ans
	elif isinstance(ans, int):
		return ans
	else:
		return ' '.join((str(ans[i]) for i in range(len(ans))))

def input_list(typ='int'):
	if typ == 'int':
		return list(map(int, input().split()))
	elif typ == 'str':
		return list(input())

def multiplyList(ls):
	res = 1
	for x in ls:
		res = res * x
	return res
t = int(input())
for q in range(t):
	l = int(input())
	ls = input_list()
	if l == 5:
		ans = multiplyList(ls)
	else:
		neg = list()
		z = list()
		pos = list()
		for i in ls:
			if i > 0:
				pos.append(i)
			elif i == 0:
				z.append(i)
			else:
				neg.append(i)
		if len(pos) + len(neg) < 5 and len(z) >= 1:
			ans = 0
		elif len(pos) + len(neg) == 5:
			if len(neg) == 1 or len(neg) == 3 or len(neg) == 5:
				ans = 0
			else:
				ans = multiplyList(pos + neg)
		else:
			neg = sorted(neg)
			pos = sorted(pos, reverse=True)
			if len(pos) >= 5:
				candidate = [multiplyList(neg[0:4]) * pos[0], multiplyList(neg[0:2]) * multiplyList(pos[0:3]), multiplyList(pos[0:5])]
				ans = max(candidate)
			elif len(pos) >= 3 and len(pos) < 5:
				candidate = [multiplyList(neg[0:4]) * pos[0], multiplyList(neg[0:2]) * multiplyList(pos[0:3])]
				ans = max(candidate)
			elif len(pos) >= 1 and len(pos) < 3:
				candidate = [multiplyList(neg[0:4]) * pos[0]]
				ans = max(candidate)
			elif len(z) >= 1:
				ans = 0
			else:
				ans = neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5]
	print(ans)


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(an, ap) = ([], [])
	(kn, kp, ko) = (0, 0, 0)
	for i in range(n):
		if a[i] < 0:
			an.append(a[i])
			kn += 1
		elif a[i] > 0:
			ap.append(a[i])
			kp += 1
		else:
			ko += 1
	an.sort()
	ap.sort()
	ap.reverse()
	check = 1
	ans1 = -1 * float('inf')
	ans2 = -1 * float('inf')
	ans3 = -1 * float('inf')
	ans4 = -1 * float('inf')
	ans5 = -1 * float('inf')
	ans6 = -1 * float('inf')
	if kp >= 5:
		ans1 = ap[0] * ap[1] * ap[2] * ap[3] * ap[4]
	if kp >= 4 and kn >= 1:
		ans2 = ap[kp - 1] * ap[kp - 2] * ap[kp - 3] * ap[kp - 4] * an[kn - 1]
	if kp >= 3 and kn >= 2:
		ans3 = ap[0] * ap[1] * ap[2] * an[0] * an[1]
	if kp >= 2 and kn >= 3:
		ans4 = ap[kp - 1] * ap[kp - 2] * an[kn - 1] * an[kn - 2] * an[kn - 3]
	if kp >= 1 and kn >= 4:
		ans5 = ap[0] * an[0] * an[1] * an[2] * an[3]
	if kn >= 5:
		ans6 = an[kn - 1] * an[kn - 2] * an[kn - 3] * an[kn - 4] * an[kn - 5]
	ans = max(ans1, ans2, ans3, ans4, ans5, ans6)
	if ko > 0:
		print(max(ans, 0))
	else:
		print(ans)


import os
import sys
from io import BytesIO, IOBase

def solution(arr, n):
	arr.sort()
	res = -float('inf')
	for i in [0, 2, 4]:
		temp = arr[:i]
		p1 = 1
		for x in temp:
			p1 *= x
		temp2 = arr[-(5 - i):]
		p2 = 1
		for x in temp2:
			p2 *= x
		res = max(res, p1 * p2)
	write(res)

def main():
	for _ in range(r_int()):
		n = r_int()
		arr = r_array()
		solution(arr, n)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


import os
import sys
from io import BytesIO, IOBase

def product_rg(arr, ch):
	ans = 1
	for i in range(ch):
		ans *= arr[-i - 1]
	return ans

def product_rg_start(arr, ch):
	ans = 1
	for i in range(ch):
		ans *= arr[i]
	return ans

def main():
	T = iin()
	while T:
		T -= 1
		n = iin()
		a = lin()
		(pv, nv) = ([], [])
		for i in a:
			if i >= 0:
				pv.append(i)
			if i < 0:
				nv.append(i)
		pv.sort()
		nv.sort(reverse=True)
		ans = product_rg_start(a, 5)
		for p1 in range(6):
			n1 = 5 - p1
			if len(pv) >= p1 and len(nv) >= n1:
				ans = max(ans, product_rg(pv, p1) * product_rg(nv, n1), product_rg_start(pv, p1) * product_rg_start(nv, n1))
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))
main()


t = int(input())
for q in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	x = l[0] * l[1] * l[n - 3] * l[n - 2] * l[n - 1]
	y = l[0] * l[1] * l[2] * l[3] * l[n - 1]
	z = l[n - 3] * l[n - 2] * l[n - 1] * l[n - 4] * l[n - 5]
	print(max(x, y, z))


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def ceil(a, b):
	return (a + b - 1) // b
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
test = 0

def solve():
	for _ in range(ii()):
		n = ii()
		a = li()
		pos = []
		neg = []
		c = 0
		for i in a:
			if i < 0:
				neg.append(i)
			elif i > 0:
				pos.append(i)
			else:
				c += 1
		neg.sort()
		pos.sort(reverse=True)
		neg1 = neg[:]
		neg1.reverse()
		ans = -inf
		for i in range(0, min(5, len(neg)) + 1):
			x = 5 - i
			if x > len(pos):
				continue
			ans1 = 1
			for j in range(x):
				ans1 *= pos[j]
			if i & 1:
				for j in range(i):
					ans1 *= neg1[j]
			else:
				for j in range(i):
					ans1 *= neg[j]
			ans = max(ans, ans1)
		if 0 in a and ans < 0:
			ans = 0
		print(ans)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
t = 1
if test:
	t = ii()
for _ in range(t):
	solve()


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(sys.stdin.readline())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def calculate(arr, i, n):
	counter = 0
	ans = 1
	while counter < 5:
		if i >= n:
			i = i % n
		ans *= arr[i]
		i += 1
		counter += 1
	return ans

def Solution(arr, n):
	arr = sorted(arr)
	ans = float('-inf')
	for i in range(n - 5, n):
		ans = max(ans, calculate(arr, i, n))
	print(ans)

def main():
	for _ in range(get_int()):
		n = get_int()
		arr = get_ints_in_list()
		Solution(arr, n)
main()


def solve(arr):
	arr.sort(key=lambda x: abs(x), reverse=True)
	ans = []
	pos_num = [a for a in arr if a > 0]
	neg_num = [a for a in arr if a < 0]
	zeros = [a for a in arr if a == 0]
	if len(pos_num) + len(neg_num) < 5:
		print(0)
		return
	if len(zeros) > 0:
		ans.append(0)
	if len(pos_num) >= 5:
		pos_ans = 1
		for i in range(5):
			pos_ans *= pos_num[i]
		ans.append(pos_ans)
	if len(pos_num) >= 1 and len(neg_num) >= 4:
		pos_ans = 1
		for i in range(4):
			pos_ans *= neg_num[i]
		pos_ans *= pos_num[0]
		ans.append(pos_ans)
	if len(pos_num) >= 3 and len(neg_num) >= 2:
		pos_ans = 1
		for i in range(3):
			pos_ans *= pos_num[i]
		pos_ans *= neg_num[0]
		pos_ans *= neg_num[1]
		ans.append(pos_ans)
	if len(neg_num) >= 5:
		pos_ans = 1
		for i in range(5):
			pos_ans *= neg_num[i]
		ans.append(pos_ans)
	pos_ans = 1
	for i in range(1, 6):
		pos_ans *= arr[-i]
	ans.append(pos_ans)
	print(max(ans))
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	solve(arr)


from functools import reduce
test_cases = int(input())

def handle() -> str:
	input()
	values = sorted([int(s) for s in input().split(' ')])
	max_value = float('-inf')
	max_value = max(max_value, reduce(lambda x, y: x * y, values[-5:]))
	max_value = max(max_value, reduce(lambda x, y: x * y, values[:2] + values[-3:]))
	max_value = max(max_value, reduce(lambda x, y: x * y, values[:4] + values[-1:]))
	return max_value
for _ in range(test_cases):
	print(handle())


def maxProductSubarrayOfSizeK(A, n, k):
	A.sort()
	product = 1
	if A[n - 1] == 0:
		return 0
	if A[n - 1] <= 0:
		for i in range(n - 1, n - k - 1, -1):
			product *= A[i]
		return product
	(i, j) = (0, n - 1)
	product *= A[j]
	j -= 1
	k -= 1
	k >>= 1
	for itr in range(k):
		left_product = A[i] * A[i + 1]
		right_product = A[j] * A[j - 1]
		if left_product > right_product:
			product *= left_product
			i += 2
		else:
			product *= right_product
			j -= 2
	return product
for _ in range(int(input())):
	n = int(input())
	print(maxProductSubarrayOfSizeK(list(map(int, input().split())), n, 5))


import sys
from functools import reduce
from operator import mul
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().strip().split(' ')))
	A.sort()
	print(max(reduce(mul, A[:5], 1), reduce(mul, A[:4] + A[-1:], 1), reduce(mul, A[:3] + A[-2:], 1), reduce(mul, A[:2] + A[-3:], 1), reduce(mul, A[:1] + A[-4:], 1), reduce(mul, A[-5:], 1)))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ne = 0
	for i in range(n):
		if a[i] < 0:
			ne = ne + 1
	m1 = a[0] * a[1] * a[2] * a[3] * a[4]
	m2 = a[0] * a[1] * a[2] * a[-1] * a[-2]
	m3 = a[0] * a[-1] * a[-2] * a[-3] * a[-4]
	if ne < 4 and ne >= 2:
		print(max(m1, m2))
	elif ne >= 4 and n != ne:
		print(max(m1, m2, m3))
	else:
		print(m1)


testcase = int(input())
for _ in range(testcase):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	k = 5
	pos = []
	neg = []
	pool = []
	zeros = 0
	for i in range(n):
		if a[i] > 0:
			pos.append(a[i])
		if a[i] < 0:
			neg.append(a[i])
		if a[i] == 0:
			zeros += 1
	pos.sort()
	neg.sort(reverse=True)
	ans = []
	if len(pos) == 0:
		if len(neg) < k or (zeros > 0 and k % 2):
			ans = [0]
		elif k % 2:
			for i in range(k):
				ans.append(neg[i])
		else:
			for i in range(k):
				ans.append(neg[-i - 1])
		k = 0
	elif len(pos) + len(neg) < k:
		ans = [0]
	else:
		if k % 2 == 1:
			ans.append(pos[-1])
			pos.pop()
			k -= 1
		while k:
			if len(pos) < 2 and len(neg) < 2:
				if zeros > 0:
					ans = [0]
					k = 0
				else:
					ans.append(pos[0])
					ans.append(neg[0])
					k -= 2
				break
			elif len(pos) < 2:
				ans.append(neg[-1])
				ans.append(neg[-2])
				neg.pop()
				neg.pop()
			elif len(neg) < 2:
				ans.append(pos[-1])
				ans.append(pos[-2])
				pos.pop()
				pos.pop()
			elif neg[-1] * neg[-2] >= pos[-1] * pos[-2]:
				ans.append(neg[-1])
				ans.append(neg[-2])
				neg.pop()
				neg.pop()
			else:
				ans.append(pos[-1])
				ans.append(pos[-2])
				pos.pop()
				pos.pop()
			k -= 2
	res = 1
	for i in range(len(ans)):
		res *= ans[i]
	print(res)


def mull(l):
	k = 1
	for i in range(len(l)):
		k = k * l[i]
	return k
for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	ne = []
	po = []
	for i in range(n):
		if l[i] < 0:
			ne.append(l[i])
		else:
			po.append(l[i])
	ne.sort()
	po.sort()
	ans = []
	if len(po) >= 5:
		k = po[-5:]
		t = mull(k)
		ans.append(t)
	if len(po) >= 4 and len(ne) >= 1:
		u = po[0:4]
		v = [ne[-1]]
		t = mull(u)
		w = mull(v)
		ans.append(t * w)
	if len(po) >= 3 and len(ne) >= 2:
		u = po[-3:]
		v = ne[0:2]
		t = mull(u)
		w = mull(v)
		ans.append(t * w)
	if len(po) >= 2 and len(ne) >= 3:
		u = po[0:2]
		v = ne[-3:]
		t = mull(u)
		w = mull(v)
		ans.append(t * w)
	if len(po) >= 1 and len(ne) >= 4:
		u = [po[-1]]
		v = ne[0:4]
		t = mull(u)
		w = mull(v)
		ans.append(t * w)
	if len(ne) >= 5:
		v = ne[-5:]
		w = mull(v)
		ans.append(w)
	ans.sort()
	print(ans[-1])


from sys import stdin
from math import ceil, gcd

def func():
	return
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = sorted(list(map(int, stdin.readline().split())), reverse=True)
	pos = len(list(filter(lambda x: x > 0, arr)))
	neg = len(list(filter(lambda x: x < 0, arr)))
	zero = n - (pos + neg)
	(a, b, c, z) = (-float('inf'), -float('inf'), -float('inf'), -float('inf'))
	if pos >= 5:
		a = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	if pos >= 3 and neg >= 2:
		b = arr[0] * arr[1] * arr[2] * arr[-1] * arr[-2]
	if pos >= 1 and neg >= 4:
		c = arr[0] * arr[-1] * arr[-2] * arr[-3] * arr[-4]
	if zero >= 1:
		z = 0
	k = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	print(max([a, b, c, z, k]))


import sys, math
input = sys.stdin.readline
t = int(input())

def takeproduct(l):
	ans = 1
	for i in l:
		ans *= i
	return ans
for r in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	pos = []
	neg = []
	for i in range(n):
		if l[i] >= 0:
			pos.append(l[i])
		else:
			neg.append(l[i])
	pos.sort()
	neg = sorted(neg, reverse=True)
	posrev = pos[::-1]
	negrev = neg[::-1]
	toggle = 1
	ans = -999999999999999999999999
	for i in range(6):
		if toggle == 1:
			temp1 = pos[:i]
			temp2 = neg[:5 - i]
			tempans = takeproduct(temp1) * takeproduct(temp2)
			if len(temp1) + len(temp2) == 5:
				ans = max(ans, tempans)
			toggle = 0
		else:
			temp1 = posrev[:i]
			temp2 = negrev[:5 - i]
			tempans = takeproduct(temp1) * takeproduct(temp2)
			if len(temp1) + len(temp2) == 5:
				ans = max(ans, tempans)
			toggle = 1
	print(ans)


import sys
import math
from collections import Counter, defaultdict
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()

def case():
	n = IN()
	a = LI()
	a.sort()
	ans = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	ans = max(ans, a[-1] * a[-2] * a[-3] * a[0] * a[1])
	ans = max(ans, a[-1] * a[3] * a[2] * a[0] * a[1])
	print(ans)
for _ in range(IN()):
	case()


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	print(max(l[-1] * l[-2] * l[-3] * l[-4] * l[-5], l[0] * l[1] * l[-1] * l[-2] * l[-3], l[0] * l[1] * l[2] * l[3] * l[-1]))


t = int(input())
for _ in range(t):
	__ = input()
	arr = list(map(int, input().split()))
	arr.sort()
	a = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	b = arr[-1] * arr[0] * arr[1] * arr[-2] * arr[-3]
	c = arr[-1] * arr[0] * arr[1] * arr[2] * arr[3]
	print(max(a, c, b))


import sys
LI = lambda : list(map(int, sys.stdin.readline().strip('\n').split()))
MI = lambda : map(int, sys.stdin.readline().strip('\n').split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline().strip('\n'))
res = []
for _ in range(II()):
	n = II()
	a = sorted(MI())
	(neg, pos, zer) = (0, 0, 0)
	for i in a:
		if i < 0:
			neg += 1
		elif i == 0:
			zer += 1
		else:
			pos += 1
	if pos >= 5:
		s = max(a[0] * a[1] * a[2] * a[3] * a[-1], a[0] * a[1] * a[-3] * a[-2] * a[-1], a[-5] * a[-4] * a[-3] * a[-2] * a[-1])
	elif pos >= 3:
		s = max(a[0] * a[1] * a[2] * a[3] * a[-1], a[0] * a[1] * a[-3] * a[-2] * a[-1])
	elif pos:
		s = a[0] * a[1] * a[2] * a[3] * a[-1]
	else:
		s = a[-5] * a[-4] * a[-3] * a[-2] * a[-1]
	res.append(s)
print(*res, sep='\n')


import sys
sys.setrecursionlimit(10000)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in a:
		if i < 0:
			b.append([-i, -1])
		else:
			b.append([i, 1])
	b.sort(key=lambda x: x[0], reverse=True)
	sign_prod = b[0][1] * b[1][1] * b[2][1] * b[3][1] * b[4][1]
	if sign_prod > 0:
		prod = b[0][0] * b[1][0] * b[2][0] * b[3][0] * b[4][0]
	else:
		smallest_neg = None
		smallest_pos = None
		for i in range(4, -1, -1):
			if smallest_neg is None and b[i][1] < 0:
				smallest_neg = i
			if smallest_pos is None and b[i][1] > 0:
				smallest_pos = i
		if len(b) == 5:
			prod = -1 * b[0][0] * b[1][0] * b[2][0] * b[3][0] * b[4][0]
		elif b[4][1] < 0 and b[5][1] > 0:
			prod = b[0][0] * b[1][0] * b[2][0] * b[3][0] * b[5][0]
		elif b[4][1] > 0 and b[5][1] < 0:
			prod = b[0][0] * b[1][0] * b[2][0] * b[3][0] * b[5][0]
		elif b[4][1] > 0 and b[5][1] > 0:
			prod1 = b[0][0] * b[1][0] * b[2][0] * b[3][0] * b[4][0] * b[5][0] // b[smallest_neg][0]
			prod2 = prod1
			for i in range(6, len(b)):
				if b[i][1] < 0:
					prod2 = b[0][0] * b[1][0] * b[2][0] * b[3][0] * b[i][0]
					break
			prod = max(prod1, prod2)
		elif b[4][1] < 0 and b[5][1] < 0:
			if smallest_pos is not None:
				prod1 = b[0][0] * b[1][0] * b[2][0] * b[3][0] * b[4][0] * b[5][0] // b[smallest_pos][0]
			else:
				prod1 = -1 * (b[n - 1][0] * b[n - 2][0] * b[n - 3][0] * b[n - 4][0] * b[n - 5][0])
			prod2 = prod1
			for i in range(6, len(b)):
				if b[i][1] > 0:
					prod2 = b[0][0] * b[1][0] * b[2][0] * b[3][0] * b[i][0]
					break
			prod = max(prod1, prod2)
	print(prod)


def helper(l):
	ret = 1
	for item in l:
		ret *= item
	return ret
t = int(input())
while t > 0:
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	a = helper(lst[:5])
	b = helper(lst[n - 5:])
	c = lst[-1] * helper(lst[:4])
	d = lst[0] * lst[1] * lst[-1] * lst[-2] * lst[-3]
	print(max(a, b, c, d))
	t -= 1


import sys

def input():
	return sys.stdin.readline()[:-1]

def getInt():
	return int(input())

def getIntIter():
	return map(int, input().split())

def getIntList():
	return list(getIntIter())

def flush():
	sys.stdout.flush()
for _ in range(getInt()):
	n = getInt()
	nums = getIntList()
	pos = []
	neg = []
	zero = 0
	for num in nums:
		if num > 0:
			pos.append(num)
		if num < 0:
			neg.append(num)
		if num == 0:
			zero += 1
	if len(pos) + len(neg) < 5:
		print(0)
	else:
		pos.sort()
		neg.sort()
		if len(pos) < 5 and len(pos) % 2 == 0 and (len(pos) + len(neg) == 5):
			if zero != 0:
				print(0)
			else:
				pos.extend(neg)
				prod = 1
				for item in pos:
					prod *= item
				print(prod)
		elif len(pos) == 0:
			if zero != 0:
				print(0)
			else:
				print(neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5])
		else:
			prod = pos[-1]
			pairs = []
			if len(pos) >= 3:
				pairs.append(pos[-2] * pos[-3])
			if len(pos) >= 5:
				pairs.append(pos[-4] * pos[-5])
			if len(neg) >= 2:
				pairs.append(neg[0] * neg[1])
			if len(neg) >= 4:
				pairs.append(neg[2] * neg[3])
			pairs.sort()
			print(prod * pairs[-1] * pairs[-2])


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def I():
	return int(sys.stdin.readline())

def neo():
	return map(int, sys.stdin.readline().split())

def Neo():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	N = I()
	A = Neo()
	A.sort()
	t = max(A[-1] * A[-2] * A[-3] * A[-4] * A[-5], A[-1] * A[0] * A[1] * A[-2] * A[-3], A[-1] * A[0] * A[1] * A[2] * A[3])
	print(t)


T = int(input())
for testcase in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	res = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	b = 1
	tmp = 1
	for i in range(5):
		tmp = tmp * a[i]
		b = 1
		for j in range(4 - i):
			b *= a[n - 1 - j]
		res = max(res, tmp * b)
	print(res)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	pos = []
	neg = []
	for i in l:
		pos.append(i)
		neg.append(i)
	pos.sort(reverse=True)
	neg.sort()
	l.sort(reverse=True)
	prim = l[0] * l[1] * l[2] * l[3] * l[4]
	ans = -10 ** 10
	ans1 = -10 ** 10
	ans2 = -10 ** 10
	ans = pos[0] * pos[1] * pos[2] * pos[3] * pos[4]
	ans1 = pos[0] * pos[1] * neg[0] * neg[1] * pos[2]
	ans2 = pos[0] * neg[1] * neg[0] * neg[2] * neg[3]
	print(max(prim, ans, ans1, ans2))


T = int(input())

def fun(A, n, k):
	A.sort()
	product = 1
	if A[n - 1] == 0 and k & 1:
		return 0
	if A[n - 1] <= 0 and k & 1:
		for i in range(n - 1, n - k - 1, -1):
			product *= A[i]
		return product
	i = 0
	j = n - 1
	if k & 1:
		product *= A[j]
		j -= 1
		k -= 1
	k >>= 1
	for itr in range(k):
		l_product = A[i] * A[i + 1]
		r_product = A[j] * A[j - 1]
		if l_product > r_product:
			product *= l_product
			i += 2
		else:
			product *= r_product
			j -= 2
	return product
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	print(fun(arr, n, 5))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	a = sorted(a)
	x = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	y = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	z = a[0] * a[1] * a[2] * a[3] * a[-1]
	print(max(x, y, z))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	A = list(map(int, input().split(' ')))
	A.sort()
	ans1 = A[-1] * A[-2] * A[-3] * A[-4] * A[-5]
	ans2 = A[-1] * A[-2] * A[-3] * A[-4] * A[0]
	ans3 = A[-1] * A[-2] * A[-3] * A[0] * A[1]
	ans4 = A[-1] * A[-2] * A[0] * A[1] * A[2]
	ans5 = A[-1] * A[0] * A[1] * A[2] * A[3]
	ans6 = A[0] * A[1] * A[2] * A[3] * A[4]
	print(max(ans1, ans2, ans3, ans4, ans5, ans6))


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(councils, a, k):
	summ = 0
	for x in a:
		summ += min(x, councils)
	return summ // councils >= k
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	n = int(input())
	a = list(read())
	a.sort()
	m = max(a[0] * a[1] * a[2] * a[3] * a[-1], a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
	m = max(m, a[0] * a[1] * a[-1] * a[-2] * a[-3])
	m = max(m, a[0] * a[1] * a[2] * a[3] * a[4])
	print(m)
for _ in range(int(input())):
	solve()


import sys
import math
from functools import reduce
input = sys.stdin.readline

def solve():
	n = int(input())
	L = list(map(int, input().split()))
	L.sort()
	l1 = L[-1:-6:-1]
	v1 = reduce(lambda x, y: x * y, l1)
	l2 = L[:5]
	v2 = reduce(lambda x, y: x * y, l2)
	a1 = max(v1, v2)

	def find(L):
		M = []
		for i in range(5):
			l1 = L[-1:-5 + i:-1]
			l2 = L[0:i + 1]
			final = l1 + l2
			prod = reduce(lambda x, y: x * y, final)
			M.append(prod)
		return max(M)
	ans1 = find(L)
	L.reverse()
	ans2 = find(L)
	print(max(ans1, ans2, a1))
for _ in range(int(input())):
	solve()


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		A = [int(x) for x in input().split()]
		plus = []
		minus = []
		zero = []
		for a in A:
			if a > 0:
				plus.append(a)
			elif a == 0:
				zero.append(a)
			else:
				minus.append(a)
		ans = -float('inf')
		if len(zero) >= 1:
			ans = 0
		plus.sort(reverse=True)
		minus.sort()
		for i in range(6):
			j = 5 - i
			tmp = 1
			if len(plus) < i or len(minus) < j:
				continue
			for ii in range(i):
				tmp *= plus[ii]
			for jj in range(j):
				tmp *= minus[jj]
			ans = max(ans, tmp)
		minus.sort(reverse=True)
		plus.sort()
		for i in range(6):
			j = 5 - i
			tmp = 1
			if len(plus) < i or len(minus) < j:
				continue
			for ii in range(i):
				tmp *= plus[ii]
			for jj in range(j):
				tmp *= minus[jj]
			ans = max(ans, tmp)
		print(ans)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	neg = []
	pos = []
	for v in map(int, input().split()):
		if v >= 0:
			pos.append(v)
		else:
			neg.append(v)
	pos.sort(reverse=True)
	neg.sort()
	lo = max(5 - len(pos), 0)
	hi = min(5, len(neg))
	out = []
	for i in range(lo, hi + 1):
		curr = 1
		for j in range(i):
			curr *= neg[j]
		for j in range(5 - i):
			curr *= pos[j]
		out.append(curr)
	neg = neg[::-1]
	for i in range(lo, hi + 1):
		curr = 1
		for j in range(i):
			curr *= neg[j]
		for j in range(5 - i):
			curr *= pos[j]
		out.append(curr)
	print(max(out))


from functools import reduce

def cheat(l, n):
	k = []
	k.append(reduce(lambda x, y: x * y, l[:5]))
	k.append(reduce(lambda x, y: x * y, l[:4] + l[n - 1:]))
	k.append(reduce(lambda x, y: x * y, l[:3] + l[n - 2:]))
	k.append(reduce(lambda x, y: x * y, l[:2] + l[n - 3:]))
	k.append(reduce(lambda x, y: x * y, l[:1] + l[n - 4:]))
	k.append(reduce(lambda x, y: x * y, l[n - 5:]))
	return k
ni = int(input())
for ki in range(ni):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 5:
		print(reduce(lambda x, y: x * y, l))
		continue
	l.sort()
	print(max(cheat(l, n)))


from math import *
from bisect import *
from collections import *
from random import *
from decimal import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	n = inp()
	a = lis()
	neg = []
	pos = []
	for i in a:
		if i > 0:
			pos.append(i)
		else:
			neg.append(i)
	pos.sort()
	neg.sort()
	x = -float('inf')
	if len(neg) >= 2 and len(pos) >= 3:
		x = max(x, neg[0] * neg[1] * pos[-1] * pos[-2] * pos[-3])
	if len(neg) >= 4 and len(pos):
		x = max(x, neg[0] * neg[1] * neg[2] * neg[3] * pos[-1])
	if len(neg) >= 5:
		x = max(x, neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5])
	if len(pos) >= 5:
		x = max(x, pos[-1] * pos[-2] * pos[-3] * pos[-4] * pos[-5])
	if n == 5:
		x = a[0] * a[1] * a[2] * a[3] * a[4]
	print(x)


def ans(A):
	A.sort()
	return max(A[-5] * A[-4] * A[-3] * A[-2] * A[-1], A[0] * A[-4] * A[-3] * A[-2] * A[-1], A[0] * A[1] * A[-3] * A[-2] * A[-1], A[0] * A[1] * A[2] * A[-2] * A[-1], A[0] * A[1] * A[2] * A[3] * A[-1], A[0] * A[1] * A[2] * A[3] * A[4])
T = int(input())
for i in range(T):
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	print(ans(arr))


input = __import__('sys').stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = sorted(map(int, input().split()), key=abs, reverse=True)
	mx = s[:5]
	cur = 1
	for i in mx:
		cur *= i
	ans = cur
	if ans == 0:
		print(ans)
		continue
	for i in range(5, n):
		for j in mx:
			ans = max(ans, cur // j * s[i])
	if all((s[i] < 0 for i in range(n))):
		ans = 1
		for i in range(5):
			ans *= s[~i]
	print(ans)


import sys
import math as mt
import collections as cc
import bisect as bi
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	l = I()
	l.sort()
	if n > 10:
		l = l[:5] + l[-5:]
	n = len(l)
	ans = -mt.inf
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				for m in range(k + 1, n):
					for t in range(m + 1, n):
						ans = max(ans, l[i] * l[j] * l[k] * l[m] * l[t])
	print(ans)


for e in [*open(0)][2::2]:
	l = sorted(map(int, e.split()))
	print(max(l[0] * l[1] * l[2] * l[3] * l[-1], l[0] * l[1] * l[-3] * l[-2] * l[-1], l[-5] * l[-4] * l[-3] * l[-2] * l[-1]))


from bisect import bisect_left
t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(map(int, input().split()))
	p = bisect_left(a, 0)
	maxp = n - p
	maxm = p
	ans = -10 ** 20
	for nminus in range(6):
		nplus = 5 - nminus
		if nminus > maxm or nplus > maxp:
			continue
		tmp = 1
		if nminus % 2 == 0:
			for i in range(n - 1, n - nplus - 1, -1):
				tmp *= a[i]
			for i in range(nminus):
				tmp *= a[i]
		else:
			for i in range(p, p + nplus):
				tmp *= a[i]
			for i in range(p - nminus, p):
				tmp *= a[i]
		ans = max(ans, tmp)
	print(ans)


import sys
for _ in range(int(input())):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	arr.sort()
	a = arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
	b = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	c = arr[0] * arr[1] * arr[2] * arr[-1] * arr[-2]
	d = arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3]
	e = arr[0] * arr[-1] * arr[-2] * arr[-3] * arr[-4]
	f = arr[-5] * arr[-1] * arr[-2] * arr[-3] * arr[-4]
	print(max(a, b, c, d, e, f))


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class smt:

	def __init__(self, l, r, arr):
		self.l = l
		self.r = r
		self.value = (1 << 31) - 1 if l < r else arr[l]
		mid = (l + r) // 2
		if l < r:
			self.left = smt(l, mid, arr)
			self.right = smt(mid + 1, r, arr)
			self.value &= self.left.value & self.right.value

	def setvalue(self, x, val):
		if self.l == self.r:
			self.value = val
			return
		mid = (self.l + self.r) // 2
		if x <= mid:
			self.left.setvalue(x, val)
		else:
			self.right.setvalue(x, val)
		self.value = self.left.value & self.right.value

	def ask(self, l, r):
		if l <= self.l and r >= self.r:
			return self.value
		val = (1 << 31) - 1
		mid = (self.l + self.r) // 2
		if l <= mid:
			val &= self.left.ask(l, r)
		if r > mid:
			val &= self.right.ask(l, r)
		return val

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [(ch, len(list(g))) for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def dfs(r, p):
	if len(g[r]) == 1 and p != 0:
		arr.append((n - 1, r))
		return 1
	res = 1
	cur = 0
	for child in g[r]:
		if child != p:
			tmp = dfs(child, r)
			res += tmp
			cur = max(cur, tmp)
	cur = max(cur, n - res)
	arr.append((cur, r))
	return res
t = N()
for i in range(t):
	n = N()
	a = RLL()
	a.sort()
	if a[-1] <= 0 or len(a) == 5:
		ans = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	else:
		big = []
		sma = []
		for i in a:
			if i > 0:
				heappush(big, i)
				if len(big) > 5:
					heappop(big)
			elif i < 0:
				heappush(sma, -i)
				if len(sma) > 5:
					heappop(sma)
		big.sort()
		sma = sorted([-s for s in sma])
		ans = 0
		if len(sma) > 3:
			ans = max(ans, big[-1] * sma[0] * sma[1] * sma[2] * sma[3])
		if len(big) >= 3 and len(sma) >= 2:
			ans = max(ans, big[-1] * big[-2] * big[-3] * sma[0] * sma[1])
		if len(big) >= 5:
			ans = max(ans, big[-1] * big[-2] * big[-3] * big[-4] * big[-5])
	print(ans)


import sys
N = int(sys.stdin.readline().strip())
MOST_NEG = -2425952699100149990000

def mult(a):
	prod = 1
	for i in a:
		prod *= i
	return prod

def mx(a, b, ai, bi):
	if ai == 0:
		return b[bi]
	if bi == 0:
		return a[ai]
	if a[ai] == MOST_NEG or b[bi] == MOST_NEG:
		return MOST_NEG
	return a[ai] * b[bi]
for _ in range(N):
	m = int(sys.stdin.readline().strip())
	nums = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	nums.sort()
	neg = []
	pos = []
	zeros = 0
	for n in nums:
		if n > 0:
			pos.append(n)
		elif n < 0:
			neg.append(n)
		else:
			zeros += 1
	(sp, lp, sn, ln) = ([MOST_NEG] * 6, [MOST_NEG] * 6, [MOST_NEG] * 6, [MOST_NEG] * 6)
	for i in range(1, 6):
		if len(pos) >= i:
			sp[i] = mult(pos[0:i])
			lp[i] = mult(pos[len(pos) - i:len(pos)])
		if len(neg) >= i:
			sn[i] = mult(neg[0:i])
			ln[i] = mult(neg[len(neg) - i:len(neg)])
	best = MOST_NEG
	for i in range(6):
		for j in range(6):
			for k in range(min(6, zeros + 1)):
				if i + j + k != 5:
					continue
				if k > 0:
					best = max(best, 0)
				else:
					best = max(best, mx(sp, sn, i, j), mx(sp, ln, i, j), mx(lp, sn, i, j), mx(lp, ln, i, j))
	print(best)


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	b = []
	z = 0
	for u in map(int, input().split()):
		if u < 0:
			a.append(u)
		if u > 0:
			b.append(u)
		if u == 0:
			z += 1
	res = -10 ** 50
	if z:
		res = 0
	for aa in range(0, 2):
		for bb in range(0, 2):
			a.sort(reverse=aa)
			b.sort(reverse=bb)
			for i in range(0, 6):
				j = 5 - i
				if len(a) >= i and len(b) >= j:
					aux = 1
					for ii in range(0, i):
						aux *= a[ii]
					for ii in range(0, j):
						aux *= b[ii]
					res = max(res, aux)
	print(res)


def syn(a):
	s = 1
	for i in a:
		s *= i
	return s

def main():
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	mx = syn(a[:5])
	for i in range(5):
		if syn(a[0:i] + a[-5 + i:]) > mx:
			mx = syn(a[0:i] + a[-5 + i:])
	print(mx)
for i in range(int(input())):
	main()


for w in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	m = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	m = max(m, a[0] * a[1] * a[2] * a[3] * a[4])
	m = max(m, a[0] * a[-1] * a[-2] * a[-3] * a[-4])
	m = max(m, a[0] * a[1] * a[2] * a[3] * a[-1])
	m = max(m, a[-1] * a[-2] * a[-3] * a[0] * a[1])
	m = max(m, a[0] * a[1] * a[2] * a[-1] * a[-2])
	print(m)


import sys
t = int(input())
f = -1000000000000000000000000000
if 1 <= t <= 2 * 10 ** 4:
	for x in range(t):
		(product, x1, x2, x3) = (int(1), int(f), int(f), int(f))
		(x4, x5, x6, x7) = (int(f), int(f), int(f), int(f))
		(neg_arr, pos_arr, zero_arr, arr) = ([], [], [], [])
		n = int(input())
		arr = list(map(int, input().split()))
		if len(arr) == n:
			for x in range(len(arr)):
				if arr[x] > 0:
					pos_arr.append(arr[x])
				elif arr[x] < 0:
					neg_arr.append(arr[x])
				elif arr[x] == 0:
					zero_arr.append(arr[x])
			pos_arr.sort()
			neg_arr.sort()
			if len(pos_arr) >= 5:
				x1 = 1
				for y in range(len(pos_arr) - 5, len(pos_arr)):
					x1 = x1 * pos_arr[y]
			if len(pos_arr) >= 3 and len(neg_arr) >= 2:
				x2 = 1
				for y in range(len(pos_arr) - 3, len(pos_arr)):
					x2 = x2 * pos_arr[y]
				for y in range(2):
					x2 = x2 * neg_arr[y]
			if len(pos_arr) >= 1 and len(neg_arr) >= 4:
				x3 = pos_arr[len(pos_arr) - 1]
				for y in range(4):
					x3 = x3 * neg_arr[y]
			if len(zero_arr) >= 1:
				x4 = 0
			if len(neg_arr) >= 5:
				x5 = 1
				for y in range(len(neg_arr) - 5, len(neg_arr)):
					x5 = x5 * neg_arr[y]
			if len(neg_arr) >= 3 and len(pos_arr) >= 2:
				x6 = 1
				for y in range(len(neg_arr) - 3, len(neg_arr)):
					x6 = x6 * neg_arr[y]
				for y in range(2):
					x6 = x6 * pos_arr[y]
			if len(neg_arr) >= 1 and len(pos_arr) >= 4:
				x7 = neg_arr[len(neg_arr) - 1]
				for y in range(4):
					x7 = x7 * pos_arr[y]
		else:
			raise ValueError('Invalid User Input')
		product = max(x1, x2, x3, x4, x5, x6, x7)
		print(product)


t = int(input())
for _ in range(t):
	n = int(input())
	a = map(int, input().split())
	(pos, neg, zero) = ([], [], False)
	for i in a:
		if i > 0:
			pos.append(i)
		elif i < 0:
			neg.append(i)
		else:
			zero = True
	pos.sort()
	neg.sort()
	res = int(-1e+18)
	for i in range(6):
		if i > len(pos):
			break
		rem = 5 - i
		if rem > len(neg):
			continue
		if rem % 2 == 0:
			(prod, id) = (1, len(pos) - 1)
			for _ in range(i):
				prod *= pos[id]
				id -= 1
			id = 0
			for _ in range(rem):
				prod *= neg[id]
				id += 1
			res = max(res, prod)
		else:
			(prod, id) = (1, 0)
			for _ in range(i):
				prod *= pos[id]
				id += 1
			id = len(neg) - 1
			for _ in range(rem):
				prod *= neg[id]
				id -= 1
			res = max(res, prod)
	if zero and res < 0:
		res = 0
	print(res)


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 + 7

def solve():
	n = II()
	li = L()
	li.sort(key=lambda x: abs(x), reverse=True)
	if max(li) < 0:
		print(li[-1] * li[-2] * li[-3] * li[-4] * li[-5])
		return
	prod = li[0] * li[1] * li[2] * li[3] * li[4]
	for i in range(5, n):
		for j in range(5):
			temp = li[i]
			for k in range(5):
				if k != j:
					temp *= li[k]
			prod = max(prod, temp)
	P(prod)
	return
t = II()
for i in range(t):
	solve()


import math
from collections import defaultdict
import functools as f
from itertools import permutations as p
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for i in range(6):
		an = 1
		for jj in range(i):
			an *= a[jj]
		for j in range(5 - i):
			an *= a[n - 1 - j]
		if i == 0:
			maxo = an
		maxo = max(maxo, an)
	print(maxo)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 1
	for i in range(n - 5, n):
		ans *= l[i]
	for i in range(1, 6):
		t = 1
		for j in range(i):
			t *= l[j]
		for j in range(5 - i):
			t *= l[::-1][j]
		ans = max(ans, int(t))
	print(ans)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for i in range(Int()):
		n = Int()
		a = List()
		a.sort()
		ans = 1
		ans = max(a[0] * a[1] * a[2] * a[3] * a[-1], a[-1] * a[-2] * a[-3] * a[-4] * a[-5], a[0] * a[1] * a[-1] * a[-2] * a[-3])
		print(ans)
solution()


import sys
import itertools
import math
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(m,) = I()
while m:
	m -= 1
	(n,) = I()
	arr = sorted(I())
	ans = -math.inf
	if n > 10:
		arr = arr[:5] + arr[-5:]
	n = len(arr)
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				for l in range(k + 1, n):
					for o in range(l + 1, n):
						ans = max(arr[i] * arr[j] * arr[k] * arr[l] * arr[o], ans)
	print(ans)


for i in range(int(input())):
	k = int(input())
	spic = list(map(int, input().split()))
	spic = sorted(spic)
	print(max(spic[-1] * spic[-2] * spic[-3] * spic[-4] * spic[-5], spic[0] * spic[1] * spic[-1] * spic[-2] * spic[-3], spic[0] * spic[1] * spic[2] * spic[3] * spic[-1]))


for test in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = []
	if n > 10:
		a = [l[-1], l[-2], l[-3], l[-4], l[-5]]
		for i in range(4):
			if l[i] < 0:
				a.append(l[i])
	else:
		a = l
	maxa = -999999999999999999
	for i in range(len(a)):
		for j in range(i + 1, len(a)):
			for k in range(j + 1, len(a)):
				for l in range(k + 1, len(a)):
					for m in range(l + 1, len(a)):
						maxa = max(maxa, a[i] * a[j] * a[k] * a[l] * a[m])
	print(maxa)


T = int(input())
while T:
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	a = A[n - 1] * A[n - 2] * A[n - 3] * A[n - 4] * A[n - 5]
	b = A[n - 1] * A[n - 2] * A[n - 3] * A[0] * A[1]
	c = A[n - 1] * A[0] * A[1] * A[2] * A[3]
	print(max(a, b, c))
	T = T - 1


t = int(input())

def prod(u):
	e = 1
	for j in u:
		e *= j
	return e
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	r = []
	z = []
	for x in a:
		if x > 0:
			p.append(x)
		elif x < 0:
			r.append(x)
		else:
			z.append(x)
	lz = len(z)
	lp = len(p)
	lr = len(r)
	if lp == 0:
		if lz == 0:
			r.sort()
			m = prod(r[-5:])
		else:
			m = 0
	elif lp == 1:
		if lr >= 4:
			r.sort()
			m = prod(r[:4]) * p[0]
		else:
			m = 0
	elif lp == 2:
		if lr >= 4:
			r.sort()
			m = prod(r[0:4]) * max(p)
		elif lz == 0:
			r.sort()
			m = prod(r[-3:]) * p[0] * p[1]
		else:
			m = 0
	elif lp == 3:
		p.sort()
		if lr < 4:
			if lr >= 2:
				r.sort()
				m = prod(r[0:2]) * prod(p)
			else:
				m = 0
		else:
			r.sort()
			m = max(prod(r[0:4]) * max(p), prod(r[0:2]) * prod(p))
	elif lp == 4:
		p.sort()
		if lr == 1:
			if lz == 0:
				m = prod(p) * r[0]
			else:
				m = 0
		elif lr == 2 or lr == 3:
			r.sort()
			m = prod(r[0:2]) * prod(p[-3:])
		elif lr >= 4:
			r.sort()
			m = max(prod(r[0:2]) * prod(p[-3:]), prod(r[0:4]) * max(p))
		else:
			m = 0
	elif lp >= 5:
		p.sort()
		mb = prod(p[-5:])
		m1 = -float('inf')
		m2 = -float('inf')
		if lr <= 1:
			m = mb
		elif lr >= 2 and lr < 4:
			r.sort()
			m1 = prod(r[0:2]) * prod(p[-3:])
			m = max(mb, m1)
		elif lr >= 4:
			r.sort()
			m1 = prod(r[0:2]) * prod(p[-3:])
			m2 = prod(r[0:4]) * max(p)
			m = max(max(m1, m2), mb)
		else:
			m = mb
	print(m)


t = input()
t = int(t)

def solve(n, arr):
	arr.sort(reverse=True)
	if arr[0] <= 0:
		print(arr[0] * arr[1] * arr[2] * arr[3] * arr[4])
		return
	candidates = []
	if arr[4] > 0:
		candidates.append(arr[0] * arr[1] * arr[2] * arr[3] * arr[4])
	if arr[2] > 0:
		candidates.append(arr[0] * arr[1] * arr[2] * -arr[-1] * -arr[-2])
	if arr[0] > 0:
		candidates.append(arr[0] * -arr[-1] * -arr[-2] * -arr[-3] * -arr[-4])
	print(max(candidates))
for i in range(t):
	n = input()
	n = int(n)
	arr = list(map(int, input().split()))
	solve(n, arr)


def getMagnitude(pair):
	return pair[0]

def getProductOfElems(elems):
	numElems = len(elems)
	product = 1
	for index in range(numElems):
		elem = elems[index]
		product *= elem[0] * elem[1]
	return product

def getNegativeNonNegativeElements(elems):
	nonNegativeElems = []
	negativeElems = []
	for index in range(N):
		elem = elems[index]
		if elem[1] == -1:
			negativeElems.append(elem)
		else:
			nonNegativeElems.append(elem)
	return (negativeElems, nonNegativeElems)

def findMaximumProductOf5(arrayWithMagnitudeAndSign):
	N = len(arrayWithMagnitudeAndSign)
	if N < 5:
		return 0
	elif N == 5:
		return getProductOfElems(arrayWithMagnitudeAndSign)
	arrayWithMagnitudeAndSign.sort(key=getMagnitude, reverse=True)
	(negativeElems, nonNegativeElems) = getNegativeNonNegativeElements(arrayWithMagnitudeAndSign)
	numNonNeg = len(nonNegativeElems)
	numNeg = len(negativeElems)
	if numNonNeg == 0:
		return getProductOfElems(negativeElems[numNeg - 5:numNeg])
	elif numNonNeg == 1 or numNonNeg == 2:
		return nonNegativeElems[0][0] * getProductOfElems(negativeElems[0:4])
	elif numNeg == 0 or numNeg == 1:
		return getProductOfElems(nonNegativeElems[0:5])
	mixedProduct = getProductOfElems(negativeElems[0:2]) * getProductOfElems(nonNegativeElems[0:3])
	if numNeg < 4 and numNonNeg <= 4:
		return mixedProduct
	elif numNeg < 4 and numNonNeg > 4:
		allNonNegProduct = getProductOfElems(nonNegativeElems[0:5])
		return max(allNonNegProduct, mixedProduct)
	fourNegProduct = nonNegativeElems[0][0] * getProductOfElems(negativeElems[0:4])
	if numNonNeg <= 4:
		return max(fourNegProduct, mixedProduct)
	allNonNegProduct = getProductOfElems(nonNegativeElems[0:5])
	return max(allNonNegProduct, fourNegProduct, mixedProduct)

def getMagnitudeAndSign(number):
	if number < 0:
		return (-number, -1)
	return (number, 1)
T = int(input())
for t in range(T):
	N = int(input())
	arrayOfNumbers = list(map(int, input().split()))
	arrayWithMagnitudeAndSign = list(map(getMagnitudeAndSign, arrayOfNumbers))
	print(findMaximumProductOf5(arrayWithMagnitudeAndSign=arrayWithMagnitudeAndSign))


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
from collections import defaultdict

def sumP(arry):
	ans = 1
	for ele in arry:
		ans *= ele
	return ans

def gift():
	for _ in range(t):
		n = int(input())
		array = list(map(int, input().split()))
		array.sort()
		if n == 5:
			yield sumP(array)
		else:
			poss = [0] * 6
			for i in range(6):
				poss[i] = sumP(array[:i]) * sumP(array[n - (5 - i):])
			yield max(poss)
t = int(input())
ans = gift()
print(*ans, sep='\n')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 0
	t1 = a[0] * a[1] * a[2] * a[3] * a[-1]
	t2 = a[0] * a[1] * a[-2] * a[-3] * a[-1]
	t3 = a[-5] * a[-4] * a[-2] * a[-3] * a[-1]
	print(max(t1, t2, t3))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if len(a) <= 10:
		f = a[:]
	else:
		f = a[:5] + a[-5:]
	fs = len(f)
	s = float('-inf')
	for i in range(fs - 4):
		for j in range(i + 1, fs - 3):
			for k in range(j + 1, fs - 2):
				for l in range(k + 1, fs - 1):
					for m in range(l + 1, fs):
						s = max(s, f[i] * f[j] * f[k] * f[l] * f[m])
	print(s)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	if n == 5:
		ans = a[0] * a[1] * a[3] * a[4] * a[2]
	else:
		a.sort()
		if a[n - 1] == 0:
			ans = 0
		elif a[n - 1] < 0:
			ans = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5]
		else:
			ans = a[n - 1]
			i = n - 2
			j = 0
			c = 0
			while i > j:
				if c == 2:
					break
				if a[i] * a[i - 1] > a[j] * a[j + 1]:
					c += 1
					ans *= a[i] * a[i - 1]
					i -= 2
				else:
					c += 1
					ans *= a[j] * a[j + 1]
					j += 2
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	max_product = -float('inf')
	for i in range(-5, 5):
		product = 1
		for j in range(5):
			product *= l[(len(l) + i + j) % len(l)]
		if product > max_product:
			max_product = product
	print(max_product)


for _ in range(int(input())):
	n = int(input())
	a = sorted([int(x) for x in input().split()])
	ans = -1e+18
	for i in range(5):
		t = 1
		for j in range(i):
			t *= a[j]
		for j in range(5 - i):
			t *= a[n - 1 - j]
		ans = max(t, ans)
	print(ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	if n == 5:
		ans = 1
		for i in a:
			ans *= i
		print(ans)
	else:
		a.sort()
		stack1 = []
		for i in range(1, 6):
			stack1.append(a[-i])
		stck2 = a[:5]
		ans = 1
		for i in stck2:
			ans *= i
		for i in range(0, 5, 2):
			temp = 1
			for j in range(i):
				temp *= stck2[j]
			for k in range(5 - i):
				temp *= stack1[k]
			ans = max(ans, temp)
		print(ans)


def solve(n, a):
	a.sort(key=abs)
	p = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	if p >= 0:
		return p
	pos = 'e'
	neg = 'e'
	for i in range(n - 6, -1, -1):
		if a[i] < 0:
			neg = i
			break
	for i in range(n - 6, -1, -1):
		if a[i] > 0:
			pos = i
			break
	ans1 = -10 ** 24
	ans2 = -10 ** 24
	if pos != 'e':
		for i in range(n - 5, n):
			if a[i] < 0:
				ans1 = p // a[i] * a[pos]
				break
	if neg != 'e':
		for i in range(n - 5, n):
			if a[i] > 0:
				ans2 = p // a[i] * a[neg]
				break
	return max(ans1, ans2, a[0] * a[1] * a[2] * a[3] * a[4])
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 5:
		print(a[0] * a[1] * a[2] * a[3] * a[4])
	else:
		print(solve(n, a))


for _ in range(int(input())):
	n = int(input())
	arr = [int(num) for num in input().split(' ')]
	arr.sort()
	ans = arr[-1]
	if ans >= 0:
		if n >= 5:
			if arr[0] * arr[1] > arr[-2] * arr[-3]:
				ans = ans * arr[0] * arr[1]
				if arr[2] * arr[3] > arr[-2] * arr[-3]:
					ans = ans * arr[2] * arr[3]
				else:
					ans = ans * arr[-2] * arr[-3]
			else:
				ans = ans * arr[-2] * arr[-3]
				if arr[-4] * arr[-5] > arr[0] * arr[1]:
					ans = ans * arr[-4] * arr[-5]
				else:
					ans = ans * arr[0] * arr[1]
	else:
		ans = ans * arr[-2] * arr[-3] * arr[-5] * arr[-4]
	print(ans)


for t in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	first = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	second = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	third = a[0] * a[1] * a[2] * a[3] * a[-1]
	print(max(first, second, third))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	temp = []
	ans = 1
	if n == 5:
		for j in range(n):
			ans *= l[j]
		print(ans)
		continue
	l.sort()
	neg = 0
	negList = []
	posList = []
	pos = 0
	for j in range(n):
		if l[j] < 0:
			neg += 1
		else:
			break
	pos = len(l) - neg
	ans2 = 1
	ans3 = 1
	ans1 = 1
	if neg >= 4 and pos >= 5:
		flag1 = 0
		for j in range(4):
			if flag1 == 0:
				ans2 *= l[j]
			if j == 1:
				flag1 = 1
			ans1 *= l[j]
		ans1 *= l[-1]
		for j in range(n - 1, n - 1 - 3, -1):
			ans2 *= l[j]
		for j in range(n - 1, n - 1 - 5, -1):
			ans3 *= l[j]
		if ans1 >= ans2 and ans1 >= ans3:
			ans = ans1
		elif ans2 >= ans1 and ans2 >= ans3:
			ans = ans2
		else:
			ans = ans3
	elif neg >= 2 and pos >= 5:
		for j in range(n - 1, n - 1 - 5, -1):
			ans3 *= l[j]
		for j in range(2):
			ans2 *= l[j]
		for j in range(n - 1, n - 1 - 3, -1):
			ans2 *= l[j]
		if ans2 >= ans3:
			ans = ans2
		else:
			ans = ans3
	elif neg >= 0 and pos >= 5:
		for j in range(n - 1, n - 1 - 5, -1):
			ans3 *= l[j]
		ans = ans3
	elif neg >= 4 and pos >= 3:
		flag1 = 0
		for j in range(4):
			if flag1 == 0:
				ans2 *= l[j]
			if j == 1:
				flag1 = 1
			ans1 *= l[j]
		ans1 *= l[-1]
		for j in range(n - 1, n - 1 - 3, -1):
			ans2 *= l[j]
		if ans1 >= ans2:
			ans = ans1
		else:
			ans = ans2
	elif neg >= 4 and pos >= 1:
		for j in range(4):
			ans1 *= l[j]
		ans1 *= l[-1]
		ans = ans1
	elif neg >= 2 and pos >= 3:
		for j in range(2):
			ans2 *= l[j]
		for j in range(n - 1, n - 1 - 3, -1):
			ans2 *= l[j]
		for j in range(n - 1, n - 1 - 5, -1):
			ans3 *= l[j]
		if ans2 >= ans3:
			ans = ans2
		else:
			ans = ans3
	else:
		for j in range(n - 1, n - 6, -1):
			ans *= l[j]
	print(ans)


def solve():
	res = []
	for _ in range(int(input())):
		n = int(input())
		l = list(map(lambda x: int(x), input().split(' ')))
		mul = 1
		if n == 5:
			for ll in l:
				mul = mul * ll
			res.append(mul)
		else:
			l.sort()
			res.append(max(l[0] * l[1] * l[2] * l[3] * l[4], l[-1] * l[-2] * l[-3] * l[-4] * l[-5], l[0] * l[1] * l[2] * l[3] * l[-1], l[-1] * l[-2] * l[-3] * l[-4] * l[0], l[0] * l[1] * l[2] * l[-2] * l[-1], l[-1] * l[-2] * l[-3] * l[0] * l[1], l[0] * l[1] * l[-3] * l[-2] * l[-1], l[-1] * l[-2] * l[0] * l[1] * l[2]))
	return res
for s in solve():
	print(s)


import sys
input = sys.stdin.buffer.readline

def print(val):
	sys.stdout.write(str(val) + '\n')

def prog():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		dp = [[[0] * 2 for i in range(6)] for i in range(n + 1)]
		dp[0][0][0] = 1
		for i in range(1, n + 1):
			for j in range(6):
				dp[i][j][0] = dp[i - 1][j][0]
				dp[i][j][1] = dp[i - 1][j][1]
				if j:
					if a[i - 1] < 0:
						dp[i][j][0] = max(dp[i][j][0], -dp[i - 1][j - 1][1] * a[i - 1])
						dp[i][j][1] = max(dp[i][j][1], -dp[i - 1][j - 1][0] * a[i - 1])
					else:
						dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j - 1][1] * a[i - 1])
						dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j - 1][0] * a[i - 1])
		dp2 = [[[10 ** 18] * 2 for i in range(6)] for i in range(n + 1)]
		dp2[0][0][0] = 1
		for i in range(1, n + 1):
			for j in range(6):
				dp2[i][j][0] = dp2[i - 1][j][0]
				dp2[i][j][1] = dp2[i - 1][j][1]
				if j:
					if a[i - 1] < 0:
						dp2[i][j][0] = min(dp2[i][j][0], -dp2[i - 1][j - 1][1] * a[i - 1])
						dp2[i][j][1] = min(dp2[i][j][1], -dp2[i - 1][j - 1][0] * a[i - 1])
					else:
						dp2[i][j][1] = min(dp2[i][j][1], dp2[i - 1][j - 1][1] * a[i - 1])
						dp2[i][j][0] = min(dp2[i][j][0], dp2[i - 1][j - 1][0] * a[i - 1])
		in_a = 0 in a
		if in_a:
			print(dp[n][5][0])
		elif dp[n][5][0] == 0:
			print(-dp2[n][5][1])
		else:
			print(dp[n][5][0])
prog()


for _ in range(int(input())):
	n = int(input())
	a = sorted([*map(int, input().split())])
	t = sum([1 if i < 0 else 0 for i in a])
	if t >= 4:
		b = a[0] * a[1] * a[2] * a[3] * a[-1]
		c = a[0] * a[1] * a[-1] * a[-2] * a[-3]
		d = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
		print(max(b, c, d))
	elif 3 >= t > 0:
		c = a[0] * a[1] * a[-1] * a[-2] * a[-3]
		d = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
		print(max(c, d))
	else:
		print(a[-1] * a[-2] * a[-3] * a[-4] * a[-5])


def prodlist(arr):
	p = 1
	for i in arr:
		p = p * i
	return p
T = int(input())
for t in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = prodlist(l[len(l) - 5:len(l)])
	b = prodlist(l[:5])
	c = prodlist(l[:4]) * l[len(l) - 1]
	d = prodlist(l[:2]) * prodlist(l[len(l) - 3:len(l)])
	print(max(a, b, c, d))


t = int(input())
for _ in range(t):
	N = int(input())
	a = list(map(int, input().split()))
	pos = []
	neg = []
	num0 = 0
	for i in range(N):
		if a[i] > 0:
			pos.append(a[i])
		elif a[i] < 0:
			neg.append(a[i])
		else:
			num0 += 1
	if N - num0 < 5:
		print(0)
	else:
		ans = []
		pos.sort(reverse=True)
		neg.sort()
		lp = len(pos)
		ln = len(neg)
		if num0 > 0:
			ans.append(0)
		if lp >= 5:
			res = pos[0] * pos[1] * pos[2] * pos[3] * pos[4]
			ans.append(res)
		if lp >= 4 and ln >= 1:
			res = pos[-1] * pos[-2] * pos[-3] * pos[-4] * neg[-1]
			ans.append(res)
		if lp >= 3 and ln >= 2:
			res = pos[0] * pos[1] * pos[2] * neg[0] * neg[1]
			ans.append(res)
		if lp >= 2 and ln >= 3:
			res = pos[-1] * pos[-2] * neg[-1] * neg[-2] * neg[-3]
			ans.append(res)
		if lp >= 1 and ln >= 4:
			res = pos[0] * neg[0] * neg[1] * neg[2] * neg[3]
			ans.append(res)
		if lp == 0:
			res = neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5]
			ans.append(res)
		print(max(ans))


import math
n = int(input())
for i in range(n):
	m = int(input())
	inp = [int(x) for x in input().split()]
	if m == 5:
		print(inp[0] * inp[1] * inp[2] * inp[3] * inp[4])
	else:
		inp.sort()
		maxEl = inp[m - 1]
		inp.remove(maxEl)
		inp.append(0)
		inp.sort()
		numNeg = inp.index(0)
		inp.remove(0)
		temp = []
		if maxEl < 0:
			print(maxEl * inp[m - 2] * inp[m - 5] * inp[m - 3] * inp[m - 4])
		else:
			for i in range(min(int(numNeg / 2), 2)):
				temp.append(inp[2 * i] * inp[2 * i + 1])
			for i in range(min(int((m - 1 - numNeg) / 2), 2)):
				temp.append(inp[m - 2 - 2 * i] * inp[m - 3 - 2 * i])
			temp.sort(reverse=True)
			print(maxEl * temp[0] * temp[1])


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter
from pprint import pprint

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	a1 = [i for i in arr if i < 0]
	a2 = [i for i in arr if i >= 0]
	a1.sort()
	a2.sort()
	l = len(a1)
	l2 = len(a2)
	ans = -float('inf')
	if l >= 5:
		ans = max(ans, a1[-5] * a1[-4] * a1[-3] * a1[-2] * a1[-1])
	if l >= 4 and l2 >= 1:
		ans = max(ans, a1[0] * a1[1] * a1[2] * a1[3] * a2[-1])
	if l >= 3 and l2 >= 2:
		ans = max(ans, a1[-3] * a1[-2] * a1[-1] * a2[0] * a2[1])
	if l >= 2 and l2 >= 3:
		ans = max(ans, a1[0] * a1[1] * a2[-3] * a2[-2] * a2[-1])
	if l >= 1 and l2 >= 4:
		ans = max(ans, a1[-1] * a2[0] * a2[1] * a2[2] * a2[3])
	if l2 >= 5:
		ans = max(ans, a2[-5] * a2[-4] * a2[-3] * a2[-2] * a2[-1])
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	main()


from itertools import combinations

def pol(a):
	if len(a) > 11:
		return a[:5] + a[len(a) - 6:]
	return a
for _ in range(int(input())):
	(n, a) = (int(input()), sorted([int(x) for x in input().split()]))
	x = []
	for (i, j, k, l, t) in combinations(pol(a), 5):
		x.append(i * j * k * l * t)
	print(max(x))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = list()
	a.sort()
	count = 0
	for i in range(n - 5, n):
		mul1 = 1
		for k in range(i, n):
			mul1 *= a[k]
		for j in range(0, count):
			mul1 *= a[j]
		count += 1
		ans.append(mul1)
	print(max(ans))


def multiply(arr1, arr2):
	mul = 1
	for elem in arr1:
		mul *= elem
	for elem in arr2:
		mul *= elem
	return mul
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	possi = [multiply(arr[:5], [1]), multiply(arr[:4], arr[-1:]), multiply(arr[:3], arr[-2:]), multiply(arr[:2], arr[-3:]), multiply(arr[:1], arr[-4:]), multiply([1], arr[-5:])]
	print(max(possi))


t = int(input())
for _ in range(t):
	n = int(input())
	tab = list(map(int, input().split()))
	tab.sort()
	val1 = tab[-1] * tab[-2] * tab[-3] * tab[-4] * tab[-5]
	val2 = tab[-1] * tab[-2] * tab[-3] * tab[-4] * tab[0]
	val3 = tab[-1] * tab[-2] * tab[-3] * tab[1] * tab[0]
	val4 = tab[-1] * tab[-2] * tab[2] * tab[1] * tab[0]
	val5 = tab[-1] * tab[3] * tab[2] * tab[1] * tab[0]
	val6 = tab[4] * tab[3] * tab[2] * tab[1] * tab[0]
	print(max(val1, val2, val3, val4, val5, val6))


t = int(input())
for i in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	if n == 5:
		print(a[0] * a[1] * a[2] * a[3] * a[4])
	else:
		r = a[n - 1]
		if r >= 0:
			if a[0] * a[1] > a[n - 2] * a[n - 3]:
				r *= a[0] * a[1]
				if a[2] * a[3] > a[n - 2] * a[n - 3]:
					r *= a[2] * a[3]
				else:
					r *= a[n - 2] * a[n - 3]
			else:
				r = r * a[n - 2] * a[n - 3]
				if a[0] * a[1] > a[n - 4] * a[n - 5]:
					r *= a[0] * a[1]
				else:
					r *= a[n - 4] * a[n - 5]
		else:
			r *= a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5]
		print(r)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	neg = []
	pos = []
	for i in l:
		if i >= 0:
			pos.append(i)
		else:
			neg.append(i)
	ans = -10 ** 18
	x = 5
	y = 0
	ha = neg.copy()
	pa = pos.copy()
	ha.sort(reverse=True)
	pos.sort(reverse=True)
	neg.sort()
	for i in range(6):
		if len(pos) >= x and len(neg) >= y:
			pro1 = 1
			pro2 = 1
			if y % 2 == 0:
				for i in range(y):
					pro2 *= neg[i]
				for i in range(x):
					pro1 *= pos[i]
			else:
				for i in range(y):
					pro2 *= ha[i]
				for i in range(x):
					pro1 *= pa[i]
			ans = max(ans, pro1 * pro2)
		x -= 1
		y += 1
	print(ans)


from math import ceil
from collections import Counter

def get_array_int():
	li = list(map(int, input().split()))
	return li
t = int(input())

def solve():
	n = int(input())
	arr = get_array_int()
	temp = sorted(arr)
	product = 1
	if temp[-1] == 0:
		print(0)
	elif temp[-1] <= 0:
		for i in range(n - 1, n - 5 - 1, -1):
			product *= temp[i]
		print(product)
	else:
		j = n - 1
		i = 0
		product *= temp[j]
		j -= 1
		k = 4
		k >>= 1
		for itr in range(k):
			left_product = temp[i] * temp[i + 1]
			right_product = temp[j] * temp[j - 1]
			if left_product > right_product:
				product *= left_product
				i += 2
			else:
				product *= right_product
				j -= 2
		print(product)
while t:
	solve()
	t -= 1


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = sorted([int(i) for i in input().split()], reverse=True)
	res1 = a[0] * a[1] * a[2] * a[3] * a[4]
	res2 = a[0] * a[1] * a[2] * a[3] * a[-1]
	res3 = a[0] * a[1] * a[2] * a[-1] * a[-2]
	res4 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	res5 = a[0] * a[-1] * a[-2] * a[-3] * a[-4]
	res6 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	res = max([res1, res2, res3, res4, res5, res6])
	print(res)


ansl = []
for _ in range(int(input())):
	n = int(input())
	al = list(map(int, input().split()))
	al.sort()
	alm = []
	alp = []
	zero = 0
	for a in al:
		if a > 0:
			alp.append(a)
		elif a < 0:
			alm.append(-a)
		else:
			zero += 1
	if alp:
		alp.sort(reverse=True)
	ans = -1 * 10 ** 18
	if len(alm) >= 4 and len(alp) >= 1:
		v = alm[0] * alm[1] * alm[2] * alm[3] * alp[0]
		ans = max(ans, v)
	if len(alm) >= 2 and len(alp) >= 3:
		v = alm[0] * alm[1] * alp[0] * alp[1] * alp[2]
		ans = max(ans, v)
	if len(alp) >= 5:
		v = alp[0] * alp[1] * alp[2] * alp[3] * alp[4]
		ans = max(ans, v)
	if zero > 0:
		ans = max(ans, 0)
	if len(alm) >= 5:
		v = alm[-1] * alm[-2] * alm[-3] * alm[-4] * alm[-5]
		ans = max(ans, -v)
	if len(alm) >= 3 and len(alp) >= 2:
		v = alm[-1] * alm[-2] * alm[-3] * alp[-1] * alp[-2]
		ans = max(ans, -v)
	if len(alm) >= 1 and len(alp) >= 4:
		v = alm[-1] * alp[-1] * alp[-2] * alp[-3] * alp[-4]
		ans = max(ans, -v)
	ansl.append(ans)
for a in ansl:
	print(a)


from sys import stdin, stdout
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def solve():
	n = inp()
	l = li()
	l.sort()
	ans1 = l[0] * l[1] * l[n - 1] * l[n - 2] * l[n - 3]
	ans2 = l[0] * l[1] * l[2] * l[3] * l[n - 1]
	ans3 = l[n - 1] * l[n - 2] * l[n - 3] * l[n - 4] * l[n - 5]
	pr(max(ans1, ans2, ans3))
for _ in range(inp()):
	solve()


for i in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	pro1 = x[0] * x[1] * x[-3] * x[-1] * x[-2]
	pro2 = x[0] * x[1] * x[2] * x[3] * x[-1]
	pro3 = x[-5] * x[-4] * x[-3] * x[-2] * x[-1]
	print(max(pro1, pro2, pro3))


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if arr[-1] < 0:
		ans = arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5]
	elif arr[-1] == 0:
		ans = 0
	else:
		ans = arr[-1]
		i = 0
		j = n - 2
		for k in range(2):
			l_p = arr[i] * arr[i + 1]
			r_p = arr[j] * arr[j - 1]
			if l_p > r_p:
				ans *= l_p
				i += 2
			else:
				ans *= r_p
				j -= 2
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	for i in s:
		if i >= 0:
			break
	else:
		print(s[0] * s[1] * s[2] * s[3] * s[4])
		continue
	print(max(s[1] * s[2] * s[3] * s[4], s[1] * s[2] * s[-1] * s[-2], s[-4] * s[-1] * s[-2] * s[-3]) * s[0])


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	ans = -inf
	for i in range(6):
		m1 = 1
		for j in range(i):
			m1 *= ar[j]
		m2 = 1
		for j in range(n - 1, n - 5 + i - 1, -1):
			m2 *= ar[j]
		ans = max(ans, m1 * m2)
	print(ans)


import sys
input = lambda : sys.stdin.readline()
for _ in range(int(input())):
	n = int(input())
	d = list(map(int, input().split()))
	a = sorted(d, key=lambda x: abs(x))
	flag = f = False
	cnt = 0
	neg = 0
	negg = 1
	for i in range(n):
		if a[i] > 0:
			flag = True
		if a[i] == 0:
			f = True
	if flag == False:
		if f == True:
			print(0)
		else:
			print(a[0] * a[1] * a[3] * a[4] * a[2])
	else:
		f3 = True
		ans = [a[0] * a[1] * a[2] * a[3] * a[4]]
		pos = []
		neg = []
		poss = negg = 0
		for i in range(n - 1, -1, -1):
			if a[i] >= 0:
				pos.append(a[i])
				poss += 1
			else:
				neg.append(a[i])
				negg += 1
		if negg >= 4 and poss > 0:
			ans.append(neg[0] * neg[1] * neg[2] * neg[3] * pos[0])
		if negg >= 2 and poss > 2:
			ans.append(neg[0] * neg[1] * pos[0] * pos[1] * pos[2])
		if poss > 4:
			ans.append(pos[0] * pos[1] * pos[2] * pos[3] * pos[4])
		print(max(ans))


for _ in range(int(input())):
	n = int(input())
	k = 5
	arr = list(map(int, input().split()))
	arr.sort()
	prod = 1
	if arr[-1] == 0 and k % 2:
		print(0)
	elif arr[-1] < 0 and k % 2:
		i = n - 1
		while k > 0:
			prod = prod * arr[i]
			i = i - 1
			k = k - 1
		print(prod)
	else:
		i = 0
		j = n - 1
		if k % 2:
			prod = arr[n - 1]
			j -= 1
			k -= 1
		for each in range(k // 2):
			if arr[i] * arr[i + 1] > arr[j] * arr[j - 1]:
				prod = prod * (arr[i] * arr[i + 1])
				i += 2
			else:
				prod = prod * (arr[j] * arr[j - 1])
				j -= 2
		print(prod)


def range_input():
	return range(int(input()))

def map_int_input():
	return map(int, input().split())
for t in range_input():
	n = int(input())
	a = list(map_int_input())
	b = [i for i in a if i < 0]
	b.sort()
	c = [i for i in a if i >= 0]
	c.sort()
	val = -float('inf')
	for i in range(6):
		temp = 1
		if i <= len(c) and 5 - i <= len(b):
			for j in range(i):
				temp *= c[len(c) - 1 - j]
			if (5 - i) % 2 == 0:
				for j in range(5 - i):
					temp *= b[j]
			else:
				for j in range(5 - i):
					temp *= b[len(b) - 1 - j]
			val = max(val, temp)
		else:
			continue
	print(int(val))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input()
	s = s.split()
	a = [int(i) for i in s]
	a = sorted(a)
	ans = -10000000000000000000
	prod = 1
	for i in range(6):
		prod = 1
		ta = a[:i]
		tb = a[len(a) - 5 + i:len(a)]
		for no in ta:
			prod *= no
		for no in tb:
			prod *= no
		if prod > ans:
			ans = prod
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c0 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	c1 = a[0] * a[-1] * a[-2] * a[-3] * a[-4]
	c2 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	c3 = a[0] * a[1] * a[2] * a[-1] * a[-2]
	c4 = a[0] * a[1] * a[2] * a[3] * a[-1]
	c5 = a[0] * a[1] * a[2] * a[3] * a[4]
	print(max(c0, c1, c2, c3, c4, c5))


from sys import stdin
from functools import reduce
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = [int(y) for y in stdin.readline().split()]
	sorted_a = sorted(a)
	print(max(reduce(lambda x, y: x * y, sorted_a[-5:]), max(reduce(lambda x, y: x * y, sorted_a[:2] + sorted_a[-3:]), reduce(lambda x, y: x * y, sorted_a[:4] + sorted_a[-1:]))))


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	p1 = 1
	for i in range(5):
		p1 *= arr[i]
	p2 = 1
	for i in range(3):
		p2 *= arr[i]
	p2 *= arr[n - 2] * arr[n - 1]
	p3 = arr[0]
	p3 *= arr[n - 4] * arr[n - 3] * arr[n - 2] * arr[n - 1]
	mx = [p1, p2, p3]
	print(max(mx))
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	l = list([int(x) for x in input().split()])
	l.sort()
	res = []
	res.append(l[n - 1] * l[n - 2] * l[n - 3] * l[n - 4] * l[n - 5])
	res.append(l[n - 1] * l[n - 2] * l[n - 3] * l[0] * l[1])
	res.append(l[n - 1] * l[2] * l[3] * l[0] * l[1])
	print(max(res))


import sys, math, heapq, copy
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import groupby
for i in range(int(input())):
	n = int(input())
	v = list(map(int, input().split()))
	v.sort()
	if v[n - 1] <= 0:
		print(v[n - 1] * v[n - 2] * v[n - 3] * v[n - 4] * v[n - 5])
		continue
	x = v[n - 1] * v[n - 2] * v[n - 3] * v[n - 4] * v[n - 5]
	y = v[n - 1] * v[n - 2] * v[n - 3] * v[1] * v[0]
	z = v[n - 1] * v[3] * v[2] * v[1] * v[0]
	print(max(x, max(y, z)))


t = int(input())
for _ in range(t):
	n = int(input())
	neg = []
	pos = []
	z = 0
	for x in map(int, input().split()):
		if x > 0:
			pos.append(x)
		elif x < 0:
			neg.append(x)
		else:
			z += 1
	lpos = len(pos)
	lneg = len(neg)
	if lpos + lneg < 5 or (lpos == 0 and z > 0):
		print(0)
	elif lpos == 0:
		neg.sort()
		prod = neg[-1]
		for i in range(4):
			prod *= neg[-2 - i]
		print(prod)
	else:
		pos.sort()
		neg.sort()
		prod = pos[-1]
		if (lpos - 1) // 2 + lneg // 2 < 2:
			if z > 0:
				print(0)
			else:
				prod = 1
				for x in pos:
					prod *= x
				for x in neg:
					prod *= x
				print(prod)
		else:
			i_pos = -2
			i_neg = 0
			p_pos = 0
			p_neg = 0
			if i_pos + lpos > 0:
				p_pos = pos[i_pos] * pos[i_pos - 1]
				i_pos -= 2
			if lneg - i_neg > 1:
				p_neg = neg[i_neg] * neg[i_neg + 1]
				i_neg += 2
			if p_pos > p_neg:
				prod *= p_pos
				if i_pos + lpos > 0:
					p_pos = pos[i_pos] * pos[i_pos - 1]
				else:
					p_pos = 0
			else:
				prod *= p_neg
				if lneg - i_neg > 1:
					p_neg = neg[i_neg] * neg[i_neg + 1]
				else:
					p_neg = 0
			prod *= max(p_pos, p_neg)
			print(prod)


for i in range(int(input())):
	n = int(input())
	data = []
	if n <= 5:
		d1 = list(map(int, input().split()))
		n5 = 1
		for v in d1:
			n5 *= v
		print(n5)
	else:
		data = sorted(list(map(int, input().split())))
		res1 = data[0] * data[1] * data[-1] * data[-2] * data[-3]
		res2 = data[0] * data[1] * data[2] * data[3] * data[-1]
		res3 = data[-5] * data[-4] * data[-1] * data[-2] * data[-3]
		reses = [res1, res2, res3]
		print(max(reses))


n = int(input().strip())
for i in range(n):
	k = int(input().strip())
	n_all = sorted([int(i) for i in input().strip().split()])
	zeros = 0
	for i in n_all:
		if i == 0:
			zeros += 1
	res = float('-inf')
	if k - zeros == 5:
		res = 1
		for i in n_all:
			if i != 0:
				res *= i
		if zeros:
			print(max(res, 0))
		else:
			print(res)
	elif k - zeros < 5:
		print(0)
	else:
		for i in (0, 2, 4):
			temp = 1
			for p in range(5 - i):
				temp *= n_all[k - p - 1]
			for n in range(i):
				temp *= n_all[n]
			res = max(res, temp)
		print(res)


from bisect import *
for _ in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	idx = bisect_left(l, 0)
	neg = l[:idx]
	lNeg = len(neg)
	lPos = n - lNeg
	ans = 1
	for i in range(5):
		ans *= l[n - 1 - i]
	for i in range(min(lNeg // 2 + 1, 3)):
		if 2 * i + lPos >= 5:
			curr = 1
			for j in range(2 * i):
				curr *= neg[j]
			for j in range(5 - 2 * i):
				curr *= l[n - 1 - j]
			ans = max(curr, ans)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	A = sorted([int(_) for _ in input().split()])
	x = A[n - 5] * A[n - 4] * A[n - 3] * A[n - 2] * A[n - 1]
	y = A[0] * A[1] * A[n - 3] * A[n - 2] * A[n - 1]
	z = A[0] * A[1] * A[2] * A[3] * A[n - 1]
	print(max(x, y, z))


import math
from sys import stdin, stdout

def getInt():
	return int(stdin.readline())

def getInts():
	return list(map(int, stdin.readline().split()))

def solve():
	n = getInt()
	ab = getInts()
	minus = []
	add = []
	x = 0
	for i in range(n):
		if ab[i] < 0:
			minus.append(ab[i])
		elif ab[i] > 0:
			add.append(ab[i])
		else:
			x = 1
	minus.sort()
	add.sort()
	has1 = [0] * 6
	has2 = [0] * 6
	has1[0] = 1
	has2[0] = 1
	for i in range(1, 6):
		if i > len(minus):
			break
		if i % 2 == 1:
			minus.reverse()
			mul = 1
			for j in range(i):
				mul = mul * minus[j]
			has1[i] = mul
			minus.reverse()
		else:
			mul = 1
			for j in range(i):
				mul = mul * minus[j]
			has1[i] = mul
	mul = 1
	add.reverse()
	for i in range(len(add)):
		if i + 1 > 5:
			break
		mul = mul * add[i]
		has2[i + 1] = mul
	ans = 1
	if x > 0:
		ans = 0
	else:
		ans = int(-1e+18)
	for i in range(6):
		if has1[i] == 0 or has2[5 - i] == 0:
			continue
		else:
			ans = max(ans, has1[i] * has2[5 - i])
	return ans

def main():
	t = getInt()
	for i in range(t):
		stdout.write(str(solve()) + '\n')
main()


for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	neg_4_pos_1 = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	neg_2_pos_3 = arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3]
	neg_0_pos_5 = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	print(max(neg_4_pos_1, neg_0_pos_5, neg_2_pos_3))


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	if n == 5:
		print(a[0] * a[1] * a[2] * a[3] * a[4])
		continue
	pos = []
	neg = []
	for k in a:
		if k >= 0:
			pos.append(k)
		else:
			neg.append(k)
	neg.sort()
	pos.sort(reverse=True)
	l_neg = len(neg)
	l_pos = len(pos)
	if l_neg <= 1:
		print(pos[0] * pos[1] * pos[2] * pos[3] * pos[4])
		continue
	if l_pos == 0:
		print(neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5])
		continue
	if l_pos == 1:
		print(pos[0] * neg[1] * neg[2] * neg[3] * neg[0])
		continue
	r = []
	if l_neg >= 4:
		r.append(pos[0] * neg[0] * neg[1] * neg[2] * neg[3])
	if l_pos >= 5:
		r.append(pos[0] * pos[1] * pos[2] * pos[3] * pos[4])
	if l_pos >= 3:
		r.append(pos[0] * pos[1] * pos[2] * neg[0] * neg[1])
	print(max(r))


t = int(input())
while t > 0:
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	if n == 5:
		print(l[0] * l[1] * l[2] * l[3] * l[4])
	else:
		p = []
		p.append(l[0] * l[1] * l[2] * l[3] * l[n - 1])
		p.append(l[0] * l[1] * l[n - 1] * l[n - 2] * l[n - 3])
		p.append(l[n - 1] * l[n - 2] * l[n - 3] * l[n - 4] * l[n - 5])
		print(max(p))
	t -= 1


cases = int(input())
out = []
for case in range(cases):
	n = int(input())
	array = [int(s) for s in input().split()]
	array.sort()
	l = 0
	r = len(array) - 1
	s = max(array[l] * array[l + 1] * array[l + 2] * array[l + 3] * array[l + 4], array[l] * array[l + 1] * array[l + 2] * array[l + 3] * array[r], array[l] * array[l + 1] * array[l + 2] * array[r - 1] * array[r], array[l] * array[l + 1] * array[r - 2] * array[r - 1] * array[r], array[l] * array[r - 3] * array[r - 2] * array[r - 1] * array[r], array[r - 4] * array[r - 3] * array[r - 2] * array[r - 1] * array[r])
	out.append(str(s))
print('\n'.join(out))


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
import sys
letters = ascii_letters
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = sorted(map(int, input().split()), key=lambda x: abs(x))
	res = 1
	for i in range(n - 5, n):
		res *= arr[i]
	if res >= 0:
		print(res)
		continue
	was = res
	for g in range(0, n - 5):
		for k in range(n - 5, n):
			res = max(res, was // arr[k] * arr[g])
	if res >= 0:
		print(res)
		continue
	res = 1
	for i in range(5):
		res *= arr[i]
	print(res)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	z = 1
	i = 1
	while i <= 5:
		z *= a[n - i]
		i += 1
	v = 1
	i = 0
	while i < 4:
		v *= a[i]
		i += 1
	v *= a[n - 1]
	h = a[0] * a[1] * a[n - 1] * a[n - 2] * a[n - 3]
	mas = [z, v, h]
	p = max(mas)
	print(p)
	t -= 1


from sys import stdin, stdout

def input():
	a = stdin.readline()
	if a[-1] == '\n':
		a = a[:-1]
	return a

def print(*argv, end='\n', sep=' '):
	n = len(argv)
	for i in range(n):
		if i == n - 1:
			stdout.write(str(argv[i]))
		else:
			stdout.write(str(argv[i]) + sep)
	stdout.write(end)
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def prod(lst):
	ans = 1
	for i in lst:
		ans *= i
	return ans

def solve(n, lst):
	lst = sorted(lst, reverse=True)
	(pos, neg) = ([], [])
	for i in lst:
		if i < 0:
			neg.append(i)
		else:
			pos.append(i)
	pos = sorted(pos, reverse=True)
	neg = sorted(neg)
	if len(pos) == 0:
		return prod(neg[-5:])
	else:
		poss = []
		for i in range(-1, min(5, len(pos))):
			rest = 5 - i - 1
			if len(pos[:i + 1] + neg[:rest]) == 5:
				poss.append(prod(pos[:i + 1] + neg[:rest]))
		return max(poss)
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	print(solve(n, lst))


for _ in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	if len(num) == 5:
		print(num[0] * num[1] * num[2] * num[3] * num[4])
	else:
		num.sort(reverse=True)
		answer = num[0] * num[1] * num[2] * num[3] * num[4]
		if num[0] * num[1] * num[2] * num[-1] * num[-2] > answer:
			answer = num[0] * num[1] * num[2] * num[-1] * num[-2]
		if num[0] * num[-1] * num[-2] * num[-3] * num[-4] > answer:
			answer = num[0] * num[-1] * num[-2] * num[-3] * num[-4]
		print(answer)


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	a.sort()
	print(max(a[0] * a[1] * a[2] * a[3] * a[-1], a[0] * a[1] * a[-1] * a[-2] * a[-3], a[-1] * a[-2] * a[-3] * a[-4] * a[-5]))


from math import gcd
import collections

def counter1(n):
	return sorted(collections.Counter(n).items(), key=lambda x: x[0])

def counter2(n):
	return sorted(collections.Counter(n).items(), key=lambda x: x[1])
mod = 10 ** 9 + 7
n = int(input())
for i in range(n):
	k = int(input())
	ll = list(map(int, input().split()))
	ll.sort()
	if len(ll) == 5:
		ans = 1
		for i in ll:
			ans *= i
		print(ans)
	else:
		ans = ll
		a = ans[0] * ans[1] * ans[2] * ans[3] * ans[4]
		b = ans[0] * ans[1] * ans[-1] * ans[-2] * ans[-3]
		c = ans[0] * ans[1] * ans[2] * ans[3] * ans[-1]
		d = ans[-1] * ans[-2] * ans[-3] * ans[-4] * ans[-5]
		print(max(a, b, c, d))


t = int(input())
for j in range(0, t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = l[0] * l[1] * l[2] * l[3] * l[4]
	b = l[0] * l[1] * l[2] * l[3] * l[-1]
	c = l[0] * l[1] * l[2] * l[-2] * l[-1]
	d = l[0] * l[1] * l[-3] * l[-2] * l[-1]
	e = l[0] * l[-4] * l[-3] * l[-2] * l[-1]
	e = l[-5] * l[-4] * l[-3] * l[-2] * l[-1]
	print(max(a, b, c, d, e))


from sys import stdin, stdout
from math import inf

def calc(lst, beg=0, used=0, to_use=5, v=1):
	if used == to_use:
		return v
	if beg == len(lst):
		return -inf
	vs = []
	for i in range(beg, len(lst)):
		vs.append(calc(lst, i + 1, used + 1, to_use, v * lst[i]))
	return max(vs)
for _ in range(0, int(stdin.readline())):
	n = int(stdin.readline())
	a = []
	b = []
	for e in map(int, stdin.readline().split()):
		if e >= 0:
			a.append(e)
		else:
			b.append(e)
	a.sort(reverse=True)
	b.sort()
	pd = 1
	if len(a) > 0:
		pd = calc(a[:5] + b[:5])
	else:
		for e in b[len(b) - 5:]:
			pd *= e
	stdout.write(f'{pd}\n')


t = int(input())
for _ in range(t):
	n = int(input())
	temp = input().split(' ')
	zero = []
	others = []
	for x in temp:
		if x == '0':
			zero.append(int(x))
		else:
			others.append(int(x))
	others.sort()
	res = 0
	if len(others) < 5:
		print(0)
	else:
		res = []
		temp = 1
		for y in range(len(others) - 5, len(others)):
			temp *= others[y]
		res.append(temp)
		temp = 1
		for y in range(len(others) - 3, len(others)):
			temp *= others[y]
		temp = temp * others[0] * others[1]
		res.append(temp)
		temp = others[len(others) - 1]
		for y in range(4):
			temp *= others[y]
		res.append(int(temp))
		if 0 in zero and max(res) < 0:
			print(0)
		else:
			print(max(res))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l, reverse=True)
	first_five = 1
	for i in range(5):
		first_five *= l[i]
	last_four = l[0]
	for i in l[-4:]:
		last_four *= i
	last_two = l[0] * l[1] * l[-1] * l[-2] * l[2]
	print(max(first_five, last_four, last_two))


def check_n_and_p(a):
	n = []
	p = []
	for i in a:
		if i < 0:
			n.append(i)
		else:
			p.append(i)
	return (n, p)

def main(neg, pos):
	if len(pos) + len(neg) == 5:
		if len(pos) % 2 == 0:
			res = 1
			for i in range(len(pos)):
				res *= pos[i]
			for i in range(len(neg)):
				res *= neg[i]
			return res
	if len(pos) == 0:
		res = neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5]
		return res
	else:
		(len_neg, len_pos) = (len(neg), len(pos))
		(res_1, res_2, res_3) = (0, 0, 0)
		if len_pos >= 5:
			res_1 = pos[-1] * pos[-2] * pos[-3] * pos[-4] * pos[-5]
		if len_neg >= 2 and len_pos >= 3:
			res_2 = neg[0] * neg[1] * pos[-1] * pos[-2] * pos[-3]
		if len_neg >= 4:
			res_3 = neg[0] * neg[1] * neg[2] * neg[3] * pos[-1]
		return max([res_1, res_2, res_3])
t = int(input())
for i in range(t):
	len_a = int(input())
	a = [int(i) for i in input().split()]
	(neg, pos) = check_n_and_p(a)
	(neg, pos) = (sorted(neg), sorted(pos))
	res = main(neg, pos)
	print(res)


import sys, os, io
input = sys.stdin.readline
T = int(input())
ans = [-float('inf')] * T
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	A.sort()
	for i in range(5):
		score = 1
		for j in range(i):
			score *= A[j]
		for j in range(1, 6 - i):
			score *= A[-j]
		ans[t] = max(ans[t], score)
print(*ans, sep='\n')


import sys

def input():
	return sys.stdin.readline().strip()

def mapint():
	return map(int, input().split())
sys.setrecursionlimit(10 ** 9)
T = int(input())
for _ in range(T):
	N = int(input())
	Xs = list(mapint())
	Xs.sort(reverse=True)
	pos = []
	neg = []
	ans = 1
	for x in Xs:
		if x >= 0:
			pos.append(x)
		else:
			neg.append(x)
	pos.sort(reverse=True)
	neg.sort()
	anss = []
	if len(pos) >= 5:
		tmp = 1
		for x in pos[:5]:
			tmp *= x
		anss.append(tmp)
	if len(neg) >= 2 and len(pos) >= 3:
		tmp = neg[0] * neg[1] * pos[0] * pos[1] * pos[2]
		anss.append(tmp)
	if len(neg) >= 4 and len(pos) >= 1:
		tmp = neg[0] * neg[1] * neg[2] * neg[3] * pos[0]
		anss.append(tmp)
	anss.append(Xs[0] * Xs[1] * Xs[2] * Xs[3] * Xs[4])
	print(max(anss))


import sys
t = int(input())
while t:
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	if li[-1] >= 0:
		one = li[0] * li[1] * li[2] * li[3] * li[-1]
		two = li[0] * li[1] * li[-2] * li[-3] * li[-1]
		three = li[-5] * li[-4] * li[-2] * li[-3] * li[-1]
		print(max(one, two, three))
	else:
		prod = li[-1] * li[-2] * li[-3] * li[-4] * li[-5]
		print(prod)
	t -= 1


from sys import stdin, stdout, stderr, maxsize
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
from math import ceil, floor
from _collections import defaultdict
from bisect import bisect_left, bisect_right
for _ in range(I()):
	n = I()
	ls = lint()
	(ne, po, ze) = (0, 0, 0)
	for i in ls:
		if i < 0:
			ne += 1
	ans = 1
	if ne == n:
		ls.sort(reverse=True)
		for i in range(5):
			ans *= ls[i]
		print(ans)
	else:
		l = sorted(ls)
		ans = max(l[-1] * l[-2] * l[-3] * l[-4] * l[-5], l[-1] * l[-2] * l[-3] * l[0] * l[1], l[0] * l[1] * l[2] * l[3] * l[-1])
		print(ans)


from functools import *
from itertools import *
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr, key=abs, reverse=True)
	mx = max(arr)
	if mx < 0:
		print(reduce(lambda x, y: x * y, arr[-5:]))
		continue
	ans = reduce(lambda x, y: x * y, arr[:5])
	for i in range(5, n):
		for j in range(5):
			tmp = arr[i]
			for k in range(5):
				if k != j:
					tmp *= arr[k]
			ans = max(tmp, ans)
	print(ans)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	return max([a[0] * a[1] * a[n - 1] * a[n - 2] * a[n - 3], a[0] * a[1] * a[2] * a[3] * a[n - 1], a[n - 5] * a[n - 4] * a[n - 3] * a[n - 2] * a[n - 1]])
for _ in range(int(input())):
	print(solve())
	print()


def getMagnitude(pair):
	if pair[1] == 1:
		return pair[0] + 0.5
	return pair[0]

def findMaximumProductOf5(arrayWithMagnitudeAndSignInfo):
	l = len(arrayWithMagnitudeAndSignInfo)
	arrayWithMagnitudeAndSignInfo.sort(key=getMagnitude, reverse=True)
	maxProduct = 1
	listOfBiggestTermIndices = [-1, -1, -1, -1, -1]
	for i in range(len(arrayWithMagnitudeAndSignInfo)):
		if arrayWithMagnitudeAndSignInfo[i][1] == 1:
			listOfBiggestTermIndices[0] = i
			break
	if listOfBiggestTermIndices[0] == -1:
		listOfBiggestTermIndices = [l - 1, l - 2, l - 3, l - 4, l - 5]
		for termIndex in range(5):
			maxProduct *= arrayWithMagnitudeAndSignInfo[listOfBiggestTermIndices[termIndex]][0] * arrayWithMagnitudeAndSignInfo[listOfBiggestTermIndices[termIndex]][1]
	else:
		largest4Negative = [-1, -1, -1, -1]
		largest4Positive = [-1, -1, -1, -1]
		neg4 = 0
		pos4 = 0
		i = 0
		while neg4 < 4 and i < len(arrayWithMagnitudeAndSignInfo):
			if i != listOfBiggestTermIndices[0] and arrayWithMagnitudeAndSignInfo[i][1] == -1:
				largest4Negative[neg4] = i
				neg4 += 1
			i += 1
		i = 0
		while pos4 < 4 and i < len(arrayWithMagnitudeAndSignInfo):
			if i != listOfBiggestTermIndices[0] and arrayWithMagnitudeAndSignInfo[i][1] == 1:
				largest4Positive[pos4] = i
				pos4 += 1
			i += 1
		largest2Negative = [largest4Negative[0], largest4Negative[1], largest4Positive[0], largest4Positive[1]]
		product1 = 1
		for termIndex1 in range(4):
			product1 *= arrayWithMagnitudeAndSignInfo[largest4Negative[termIndex1]][0]
		product2 = 1
		for termIndex1 in range(4):
			product2 *= arrayWithMagnitudeAndSignInfo[largest4Positive[termIndex1]][0]
		product3 = 1
		for termIndex1 in range(4):
			product3 *= arrayWithMagnitudeAndSignInfo[largest2Negative[termIndex1]][0]
		if neg4 == 4 and pos4 == 4:
			maxProduct = arrayWithMagnitudeAndSignInfo[listOfBiggestTermIndices[0]][0] * max(product1, product2, product3)
		elif neg4 == 4 and pos4 >= 2:
			maxProduct = arrayWithMagnitudeAndSignInfo[listOfBiggestTermIndices[0]][0] * max(product1, product3)
		elif pos4 == 4 and neg4 >= 2:
			maxProduct = arrayWithMagnitudeAndSignInfo[listOfBiggestTermIndices[0]][0] * max(product2, product3)
		elif neg4 == 4:
			maxProduct = arrayWithMagnitudeAndSignInfo[listOfBiggestTermIndices[0]][0] * product1
		elif pos4 == 4:
			maxProduct = arrayWithMagnitudeAndSignInfo[listOfBiggestTermIndices[0]][0] * product2
		elif neg4 >= 2 and pos4 >= 2:
			maxProduct = arrayWithMagnitudeAndSignInfo[listOfBiggestTermIndices[0]][0] * product3
		else:
			listOfBiggestTermIndices = [l - 1, l - 2, l - 3, l - 4, l - 5]
			for termIndex in range(5):
				maxProduct *= arrayWithMagnitudeAndSignInfo[listOfBiggestTermIndices[termIndex]][0] * arrayWithMagnitudeAndSignInfo[listOfBiggestTermIndices[termIndex]][1]
	return maxProduct

def getMagnitudeAndSign(number):
	if number < 0:
		return (-number, -1)
	return (number, 1)
T = int(input())
for t in range(T):
	N = int(input())
	arrayOfNumbers = list(map(int, input().split()))
	arrayWithMagnitudeAndSignInfo = list(map(getMagnitudeAndSign, arrayOfNumbers))
	print(findMaximumProductOf5(arrayWithMagnitudeAndSignInfo=arrayWithMagnitudeAndSignInfo))


from functools import *
from operator import *
for s in [*open(0)][2::2]:
	a = sorted(map(int, s.split()))
	print(max((reduce(mul, a[:i], 1) * reduce(mul, a[i - 5:], 1) for i in range(5))))


import sys

def multiple_input():
	return map(int, sys.stdin.readline().strip().split())

def list_input():
	return list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	n = int(input())
	a = list_input()
	a.sort()
	(neg, pos) = ([], [])
	num = []
	for i in a:
		if i < 0:
			neg.append(i)
			num.append(-i)
		else:
			pos.append(i)
			num.append(i)
	num.sort()
	ans = []
	(l1, l2) = (len(pos), len(neg))
	if l1 >= 5:
		s = pos[-1] * pos[-2] * pos[-3] * pos[-4] * pos[-5]
		ans.append(s)
	if l1 >= 3 and l2 >= 2:
		s = pos[-1] * pos[-2] * pos[-3] * neg[1] * neg[0]
		ans.append(s)
	if l1 >= 1 and l2 >= 4:
		s = pos[-1] * neg[2] * neg[3] * neg[1] * neg[0]
		ans.append(s)
	if len(ans) == 0:
		s = num[4] * num[2] * num[3] * num[1] * num[0]
		ans.append(-s)
	print(max(ans))


import sys
n = int(input())
for i in range(n):
	t = int(input())
	arr = [int(i) for i in input().split()]
	ans = -sys.maxsize
	arr.sort()
	if len(arr) == 5:
		ans = 1
		for i in arr:
			ans *= i
		print(ans)
	else:
		ans = arr
		a = ans[0] * ans[1] * ans[2] * ans[3] * ans[4]
		b = ans[0] * ans[1] * ans[-1] * ans[-2] * ans[-3]
		c = ans[0] * ans[1] * ans[2] * ans[3] * ans[-1]
		d = ans[-1] * ans[-2] * ans[-3] * ans[-4] * ans[-5]
		print(max(a, b, c, d))


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, arr):
	arr.sort()
	a = arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5]
	b = arr[0] * arr[1] * arr[-1] * arr[-2] * arr[-3]
	c = arr[0] * arr[1] * arr[2] * arr[3] * arr[-1]
	print(max(a, b, c))
for _ in range(int(input())):
	n = int(input())
	arr = int_arr()
	solve(n, arr)


for _ in range(int(input())):
	n = int(input())
	z = list(map(int, input().split()))
	z.sort(reverse=True)
	a = z[0] * z[1] * z[2] * z[3] * z[4]
	b = z[0] * z[-1] * z[-2] * z[-3] * z[-4]
	c = z[0] * z[1] * z[2] * z[-1] * z[-2]
	print(max(a, b, c))


import os
import sys
from io import BytesIO, IOBase

def maxProductSubarrayOfSizeK(A, n, k):
	A.sort()
	product = 1
	if A[n - 1] == 0 and k & 1:
		return 0
	if A[n - 1] <= 0 and k & 1:
		for i in range(n - 1, n - k - 1, -1):
			product *= A[i]
		return product
	i = 0
	j = n - 1
	if k & 1:
		product *= A[j]
		j -= 1
		k -= 1
	k >>= 1
	for itr in range(k):
		left_product = A[i] * A[i + 1]
		right_product = A[j] * A[j - 1]
		if left_product > right_product:
			product *= left_product
			i += 2
		else:
			product *= right_product
			j -= 2
	return product

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		print(maxProductSubarrayOfSizeK(a, n, 5))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	ans = 1
	cn = 0
	for i in range(n):
		if a[i] < 0:
			cn += 1
	cp = n - cn
	for i in range(1, 6):
		ans *= a[-i]
	if cn == n:
		print(ans)
	else:
		x = a[:4] + [a[-1]]
		y = a[:2] + a[-3:]
		ans1 = ans2 = 1
		for i in range(5):
			ans1 *= x[i]
		for i in range(5):
			ans2 *= y[i]
		print(max(ans, ans1, ans2))


for _ in ' ' * int(input()):
	n = int(input())
	a = list(map(int, input().split()))
	cntp = 0
	cnto = 0
	cntn = 0
	cntpl = []
	cntol = []
	cntnl = []
	for i in range(n):
		if a[i] < 0:
			cntn += 1
			cntnl.append(abs(a[i]))
		elif a[i] > 0:
			cntp += 1
			cntpl.append(a[i])
		else:
			cnto += 1
			cntol.append(a[i])
	cntol.sort()
	cntnl.sort()
	cntpl.sort()
	cntol = cntol[::-1]
	cntnl = cntnl[::-1]
	cntpl = cntpl[::-1]
	s = 0
	if len(cntnl) >= 4 and len(cntpl) >= 1:
		s = max(s, cntnl[0] * cntnl[1] * cntnl[2] * cntnl[3] * cntpl[0])
	if len(cntnl) >= 2 and len(cntpl) >= 3:
		s = max(s, cntnl[0] * cntnl[1] * cntpl[0] * cntpl[1] * cntpl[2])
	if len(cntpl) >= 5:
		s = max(s, cntpl[0] * cntpl[1] * cntpl[2] * cntpl[3] * cntpl[4])
	if len(cntpl) == 0:
		if len(cntol) > 0:
			s = 0
		else:
			s = -(cntnl[-1] * cntnl[-2] * cntnl[-3] * cntnl[-4] * cntnl[-5])
	if len(cntol) == n:
		s = 0
	if len(cntol) >= 1:
		s = max(s, 0)
	if n == 5:
		s = a[0] * a[1] * a[2] * a[3] * a[4]
	print(s)


def prod(arr):
	p = 1
	for a in arr:
		p *= a
	return p
for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	array.sort()
	p1 = prod(array[:4]) * array[-1]
	p2 = prod(array[:2]) * prod(array[n - 3:])
	p3 = prod(array[n - 5:])
	print(max(p1, p2, p3))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	a = lis()
	neg = []
	pos = []
	for i in range(n):
		if a[i] < 0:
			neg.append(a[i])
		else:
			pos.append(a[i])
	ans = 1
	for i in range(5):
		ans *= a[i]
	pos = sorted(pos)[::-1]
	neg = sorted(neg)
	if len(pos) >= 5:
		curr = 1
		for i in range(5):
			curr *= pos[i]
		ans = max(ans, curr)
	if len(pos) >= 3 and len(neg) >= 2:
		curr = 1
		for i in range(3):
			curr *= pos[i]
		for i in range(2):
			curr *= neg[i]
		ans = max(ans, curr)
	if len(pos) > 0 and len(neg) >= 4:
		curr = 1
		for i in range(1):
			curr *= pos[i]
		for i in range(4):
			curr *= neg[i]
		ans = max(ans, curr)
	if len(neg) > 4:
		curr = 1
		neg = neg[::-1]
		for i in range(5):
			curr *= neg[i]
		ans = max(ans, curr)
	print(ans)
testcase(int(inp()))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(n) for n in input().split(' ')]
	arr = sorted(arr)
	res_a = 1
	for i in range(n - 5, n):
		res_a *= arr[i]
	res_b = 1
	for i in range(0, 2):
		res_b *= arr[i]
	for i in range(n - 3, n):
		res_b *= arr[i]
	res_c = 1
	for i in range(0, 4):
		res_c *= arr[i]
	res_c *= arr[n - 1]
	print(max(res_a, res_b, res_c))


import math, sys
from collections import defaultdict, Counter, deque
from functools import reduce
INF = float('inf')
MOD = int(1000000000.0) + 7

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = defaultdict(int)
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors[i] += 1
			n //= i
		i += 1
	if n > 1:
		factors[n] += 1
	return factors

def a():
	n = int(input())
	arr = array()
	m = Counter(arr)
	mex1 = -1
	mex2 = -1
	for k in sorted(m.keys()):
		if mex1 + 1 != k:
			break
		mex1 += 1
		if mex2 + 1 == k and m[k] >= 2:
			mex2 += 1
	print(mex1 + mex2 + 2)

def b():
	n = int(input())
	arr = array()
	arr.sort()
	ans = -INF
	for i in range(6):
		mul = 1
		l = i
		r = n - (5 - i)
		for i in range(0, l):
			mul *= arr[i]
		for i in range(r, n):
			mul *= arr[i]
		ans = max(ans, mul)
	print(ans)

class DSU:

	def __init__(self, n):
		self.p = [i for i in range(n + 1)]
		self.size = [1 for i in range(n + 1)]
		self.minmax = [[i, i] for i in range(n + 1)]
		self.n = n

	def find(self, node):
		if self.p[node] != node:
			self.p[node] = self.find(self.p[node])
		return self.p[node]

	def union(self, source, dest):
		source = self.find(source)
		dest = self.find(dest)
		if source != dest:
			if self.size[source] < self.size[dest]:
				(source, dest) = (dest, source)
			self.p[dest] = source
			self.size[source] += self.size[dest]
			mini = min(self.minmax[source][0], self.minmax[dest][0])
			maxi = max(self.minmax[source][1], self.minmax[dest][1])
			self.minmax[source] = [mini, maxi]

def input():
	return sys.stdin.readline().rstrip('\n')

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(sep)
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))
t = 1
t = int(input())
for _ in range(t):
	b()


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	left = 0
	right = n - 1
	ans = 1
	c = 0
	ans = max(arr[n - 1] * arr[n - 2] * arr[n - 3] * arr[n - 4] * arr[n - 5], arr[0] * arr[1] * arr[n - 1] * arr[n - 2] * arr[n - 3], arr[0] * arr[1] * arr[2] * arr[3] * arr[-1])
	print(ans)


for i in range(int(input())):
	n = int(input())
	no = sorted(map(int, input().split(' ')))
	productone = no[0] * no[1] * no[n - 1] * no[n - 2] * no[n - 3]
	producttwo = no[0] * no[1] * no[2] * no[3] * no[n - 1]
	productthree = no[n - 1] * no[n - 2] * no[n - 3] * no[n - 4] * no[n - 5]
	print(max(productone, producttwo, productthree))


import sys
input = sys.stdin.buffer.readline

def solution():
	n = int(input())
	l = list(map(int, input().split()))
	if n == 5:
		ans = 1
		for i in range(n):
			ans *= l[i]
	else:
		l.sort()
		if max(l) == 0:
			ans = 0
		elif max(l) < 0:
			ans = 1
			i = n - 1
			cnt = 0
			while cnt != 5:
				ans *= l[i]
				i -= 1
				cnt += 1
		else:
			ans = 1
			i = 0
			j = n - 1
			k = 5
			if k & 1:
				ans *= l[j]
				j -= 1
				k -= 1
			k >>= 1
			for itr in range(k):
				left_product = l[i] * l[i + 1]
				right_product = l[j] * l[j - 1]
				if left_product > right_product:
					ans *= left_product
					i += 2
				else:
					ans *= right_product
					j -= 2
	print(ans)
t = int(input())
for _ in range(t):
	solution()


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	x = arr[0] * arr[1] * arr[n - 1] * arr[n - 2] * arr[n - 3]
	y = arr[0] * arr[1] * arr[2] * arr[3] * arr[n - 1]
	z = arr[n - 5] * arr[n - 4] * arr[n - 1] * arr[n - 2] * arr[n - 3]
	ans = max(x, y, z)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a)
	p1 = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5]
	p2 = a[0] * a[1] * a[n - 1] * a[n - 2] * a[n - 3]
	p3 = a[0] * a[1] * a[2] * a[3] * a[n - 1]
	p4 = a[0] * a[1] * a[2] * a[3] * a[4]
	print(max(p1, p2, p3, p4))


import sys
input = sys.stdin.readline

def solve(n, a):
	a = [0] + a
	min_table = [[float('inf')] * (n + 1) for _ in range(6)]
	max_table = [[float('-inf')] * (n + 1) for _ in range(6)]
	for j in range(1, n + 1):
		min_table[1][j] = min(a[j], min_table[1][j - 1])
		max_table[1][j] = max(a[j], max_table[1][j - 1])
	for i in range(2, 6):
		for j in range(i, n + 1):
			if a[j] > 0:
				min_table[i][j] = min(a[j] * min_table[i - 1][j - 1], min_table[i][j - 1])
				max_table[i][j] = max(a[j] * max_table[i - 1][j - 1], max_table[i][j - 1])
			else:
				min_table[i][j] = min(a[j] * max_table[i - 1][j - 1], min_table[i][j - 1])
				max_table[i][j] = max(a[j] * min_table[i - 1][j - 1], max_table[i][j - 1])
	return max_table[5][n]
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	v = solve(n, a)
	print(v)


t = int(input())
while t > 0:
	n = int(input())
	x = [int(i) for i in input().split()]
	x.sort()
	g1 = x[n - 5] * x[n - 4] * x[n - 3] * x[n - 2] * x[n - 1]
	g2 = x[n - 4] * x[n - 3] * x[n - 2] * x[n - 1] * x[0]
	g3 = x[n - 3] * x[n - 2] * x[n - 1] * x[0] * x[1]
	g4 = x[n - 2] * x[n - 1] * x[0] * x[1] * x[2]
	g5 = x[n - 1] * x[0] * x[1] * x[2] * x[3]
	g6 = x[0] * x[1] * x[2] * x[3] * x[4]
	print(max(g1, g2, g3, g4, g5, g6))
	t -= 1


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def solve():
	n = int(inp())
	A = lis()
	A.sort()
	product = A[-1] * A[-2] * A[-3] * A[-4] * A[-5]
	if A[0] < 0 and A[1] < 0:
		if A[0] * A[1] * A[-1] * A[-2] * A[-3] > product:
			product = A[0] * A[1] * A[-1] * A[-2] * A[-3]
	if A[0] < 0 and A[1] < 0 and (A[2] < 0) and (A[3] < 0):
		if A[0] * A[1] * A[2] * A[3] * A[-1] > product:
			product = A[0] * A[1] * A[2] * A[3] * A[-1]
	print(product)
testcase(int(inp()))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	prod1 = 1
	for i in range(4):
		prod1 = prod1 * arr[i]
	prod1 = prod1 * arr[-1]
	prod2 = 1
	for i in range(2):
		prod2 = prod2 * arr[i]
	prod2 = prod2 * arr[-1] * arr[-2] * arr[-3]
	prod3 = 1
	for i in range(5):
		prod3 = prod3 * arr[i]
	prod4 = 1
	for i in range(5):
		prod4 = prod4 * arr[i - 5]
	print(max(prod1, prod2, prod3, prod4))


t1 = int(input())

def mult(arr):
	x = 1
	for i in arr:
		x = x * i
	return x
for _ in range(t1):
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 5:
		print(mult(arr))
		continue
	neg = []
	pos = []
	zero = 0
	for i in arr:
		if i < 0:
			neg.append(i)
		elif i == 0:
			zero = 1
			pos.append(i)
		else:
			pos.append(i)
	neg = sorted(neg)
	ans = 0
	pos = sorted(pos, reverse=True)
	if pos == [] and zero == 0:
		ans = mult(neg[-5:-1]) * neg[-1]
	elif pos == [0] and zero == 1:
		ans = 0
	else:
		if len(neg) >= 2 and len(pos) >= 3:
			ans = mult(neg[:2]) * mult(pos[:3])
		if len(neg) >= 4 and len(pos) >= 1:
			ans = max(ans, mult(neg[:4]) * pos[0])
		if len(pos) >= 5:
			ans = max(ans, mult(pos[:5]))
	print(ans)


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	a1 = a.copy()
	mas = []
	for i in range(n):
		if a[i] == 0:
			mas.append(i)
	if n - len(mas) >= 5:
		f = 0
		for i in mas:
			del a[i - f]
			f += 1
	ans = []
	cur = 1
	for i in range(5):
		cur *= a[i]
	ans.append(cur)
	cur = 1
	for i in range(4):
		cur *= a[i]
	cur *= a[-1]
	ans.append(cur)
	cur = 1
	for i in range(3):
		cur *= a[i]
	cur *= a[-1]
	cur *= a[-2]
	ans.append(cur)
	cur = 1
	for i in range(2):
		cur *= a[i]
	cur *= a[-1]
	cur *= a[-2]
	cur *= a[-3]
	ans.append(cur)
	cur = 1
	for i in range(1):
		cur *= a[i]
	cur *= a[-1]
	cur *= a[-2]
	cur *= a[-3]
	cur *= a[-4]
	ans.append(cur)
	cur = 1
	cur *= a[-1]
	cur *= a[-2]
	cur *= a[-3]
	cur *= a[-4]
	cur *= a[-5]
	ans.append(cur)
	aa = max(ans)
	if 0 in a1:
		aa = max(0, aa)
	print(aa)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ne = []
	p = []
	for i in range(n):
		if arr[i] < 0:
			ne.append(-1 * arr[i])
		else:
			p.append(arr[i])
	ne.sort()
	p.sort(reverse=True)
	if n == 5:
		out = 1
		for i in arr:
			out *= i
		print(out)
	elif len(p) == 0:
		out = 1
		i = 0
		while i < 5:
			out *= ne[i]
			i += 1
		print(-1 * out)
	else:
		out = p[0]
		p = p[1:]
		ne.reverse()
		i = 0
		while i < 4:
			if len(ne) >= 2:
				if len(p) >= 2:
					if ne[0] * ne[1] > p[0] * p[1]:
						out *= ne[0] * ne[1]
						ne = ne[2:]
					else:
						out *= p[0] * p[1]
						p = p[2:]
				else:
					out *= ne[0] * ne[1]
					ne = ne[2:]
			else:
				out *= p[0] * p[1]
				p = p[2:]
			i += 2
		print(out)


class Node:

	def __init__(self, val):
		self.val = val
		self.children = None
		self.centroid = None
		self.edges = []

class Graph:

	def __init__(self):
		self.root = None

	def add_edge(self, a, b):
		if self.root == None:
			self.root = a
		a.edges.append(b)
		b.edges.append(a)

def dfs_children(g, root, visited):
	visited.add(root.val)
	c = 0
	for i in root.edges:
		if i.val not in visited:
			visited.add(i.val)
			c += 1 + dfs_children(g, i, visited)
	root.children = c
	return root.children

def dfs_centroids(g, root, visited, n, ce):
	visited.add(root.val)
	c = -1
	t = 0
	for i in root.edges:
		if i.val not in visited:
			visited.add(i.val)
			c = max(c, i.children + 1)
			dfs_centroids(g, i, visited, n, ce)
			t += i.children + 1
	c = max(c, n - t - 1)
	root.centroid = c
	if c in ce:
		ce[c].append(root)
	else:
		ce[c] = [root]
	return root.centroid

def get_leaf(root, li, visited, noti):
	if root.val == noti.val:
		return False
	visited.add(root.val)
	flag = True
	for i in root.edges:
		if i.val not in visited and i.val != noti.val:
			visited.add(i.val)
			li[0] = root
			li[1] = i
			flag = flag & get_leaf(root, li, visited, noti)
	return flag

def pro(li):
	p = 1
	for i in li:
		p *= i
	return p

def process():
	n = int(input())
	li = list(map(int, input().split()))
	ans = []
	s1 = list(li)
	s2 = list(li)
	s1.sort()
	s2.sort(reverse=True)
	ans.append(pro(s1[:5]))
	ans.append(pro(s1[:4]) * s2[0])
	ans.append(pro(s1[:3]) * pro(s2[:2]))
	ans.append(pro(s1[:2]) * pro(s2[:3]))
	ans.append(pro(s1[:1]) * pro(s2[:4]))
	ans.append(pro(s2[:5]))
	print(max(ans))
tests = int(input())
for i in range(tests):
	process()


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	ans = -1e+18
	ans = max(ans, l[-5] * l[-4] * l[-3] * l[-2] * l[-1])
	ans = max(ans, l[0] * l[-4] * l[-3] * l[-2] * l[-1])
	ans = max(ans, l[0] * l[1] * l[-3] * l[-2] * l[-1])
	ans = max(ans, l[0] * l[1] * l[2] * l[-2] * l[-1])
	ans = max(ans, l[0] * l[1] * l[2] * l[3] * l[-1])
	ans = max(ans, l[0] * l[1] * l[2] * l[3] * l[4])
	print(ans)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	one = l[-1] * l[-2] * (l[-3] * l[-4]) * l[-5]
	two = l[0] * l[1] * (l[2] * l[3]) * l[-1]
	three = l[0] * (l[1] * l[-1]) * (l[-2] * l[-3])
	four = l[0] * l[1] * (l[2] * l[3]) * l[4]
	print(max(one, two, three, four))


T = int(input())
while T:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	negs0 = a[-5] * a[-4] * a[-3] * a[-2] * a[-1]
	negs2 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	negs4 = a[0] * a[1] * a[2] * a[3] * a[-1]
	print(max(negs0, negs2, negs4))
	T -= 1


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	n = int(ii())
	data = sorted(idata())
	print(max(data[-1] * data[-2] * data[-3] * data[-4] * data[-5], data[0] * data[1] * data[-1] * data[-2] * data[-3], data[0] * data[1] * data[2] * data[3] * data[-1]))
	return
for t in range(int(ii())):
	solve()


import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
sys.setrecursionlimit(20000)
T = int(input())
for _ in range(T):
	n = get_ints()[0]
	A = get_ints()
	A.sort()
	x = A[-1] * A[-2] * A[-3] * A[-4] * A[-5]
	y = A[-1] * A[-2] * A[-3] * A[0] * A[1]
	z = A[-1] * A[0] * A[1] * A[2] * A[3]
	print(max([x, y, z]))


import os
from io import BytesIO, IOBase
import sys

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		pos = []
		neg = []
		c = 0
		for i in range(n):
			if a[i] > 0:
				pos.append(a[i])
			if a[i] < 0:
				neg.append(-a[i])
			if a[i] == 0:
				c += 1
		pos.sort(reverse=True)
		neg.sort(reverse=True)
		ans = -10 ** 20
		if len(pos) >= 5:
			tans = 1
			for i in range(5):
				tans *= pos[i]
			ans = max(ans, tans)
		if len(pos) >= 1 and len(neg) >= 4:
			tans = 1
			for i in range(1):
				tans *= pos[i]
			for i in range(4):
				tans *= neg[i]
			ans = max(ans, tans)
		if len(pos) >= 3 and len(neg) >= 2:
			tans = 1
			for i in range(3):
				tans *= pos[i]
			for i in range(2):
				tans *= neg[i]
			ans = max(ans, tans)
		pos.sort()
		neg.sort()
		if len(neg) >= 5:
			tans = -1
			for i in range(5):
				tans *= neg[i]
			ans = max(ans, tans)
		if len(pos) >= 2 and len(neg) >= 3:
			tans = -1
			for i in range(2):
				tans *= pos[i]
			for i in range(3):
				tans *= neg[i]
			ans = max(ans, tans)
		if len(pos) >= 4 and len(neg) >= 1:
			tans = -1
			for i in range(4):
				tans *= pos[i]
			for i in range(1):
				tans *= neg[i]
			ans = max(ans, tans)
		if c > 0:
			ans = max(ans, 0)
		print(ans)
	return
BUFSIZE = 1048576

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.buffer.readline
	for _ in range(int(input())):
		N = int(input())
		A = list(map(int, input().split()))
		pos = []
		neg = []
		for a in A:
			if a < 0:
				neg.append(a)
			else:
				pos.append(a)
		pos.sort()
		neg.sort(reverse=True)
		ans = -float('inf')
		for ne in range(6):
			po = 5 - ne
			tmp = 1
			if ne & 1:
				if len(pos) >= po and len(neg) >= ne:
					for i in range(po):
						tmp *= pos[i]
					for i in range(ne):
						tmp *= neg[i]
					ans = max(ans, tmp)
			elif len(pos) >= po and len(neg) >= ne:
				for i in range(po):
					tmp *= pos[-i - 1]
				for i in range(ne):
					tmp *= neg[-i - 1]
				ans = max(ans, tmp)
		print(ans)
main()


def maxprod(n, a):
	a.sort()
	if n == 5 or a[0] * a[-1] >= 0:
		return a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	prod = a[n - 1]
	(l, r) = (0, n - 2)
	if a[l] * a[l + 1] > a[r] * a[r - 1]:
		prod = prod * a[l] * a[l + 1]
		l = l + 2
	else:
		prod = prod * a[r] * a[r - 1]
		r = r - 2
	if a[l] * a[l + 1] > a[r] * a[r - 1]:
		prod = prod * a[l] * a[l + 1]
	else:
		prod = prod * a[r] * a[r - 1]
	return prod
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(maxprod(n, a))


t = int(input())
while t:
	n = int(input())
	a = [int(i) for i in input().split()]
	pos = []
	neg = []
	for ele in a:
		if ele > 0:
			pos.append(ele)
		else:
			neg.append(ele)
	pos.sort()
	neg.sort()
	if len(pos) == 0:
		ans = 1
		for i in range(1, 6):
			ans *= neg[-i]
		print(ans)
	elif len(neg) == 0:
		ans = 1
		for i in range(1, 6):
			ans *= pos[-i]
		print(ans)
	else:
		ans = float('-inf')
		for i in range(1, 6):
			if len(pos) < i or len(neg) < 5 - i:
				continue
			temp = 1
			for j in range(1, i + 1):
				temp *= pos[-j]
			if (5 - i) % 2 == 0:
				for j in range(5 - i):
					temp *= neg[j]
			else:
				for j in range(1, 5 - i + 1):
					temp *= neg[-j]
			ans = max(ans, temp)
		print(ans)
	t -= 1


for _ in range(int(input())):
	N = int(input())
	A = [[i, 1] if i > 0 else [-i, -1] for i in map(int, input().split())]
	A.sort()
	ans = 1
	for i in range(5):
		ans *= A[i][0] * A[i][1]
	x = 1
	for i in range(-5, 0):
		x *= A[i][0] * A[i][1]
	if x >= 0:
		print(x)
		continue
	y = x
	for i in range(-5, 0):
		if A[i][1] == -1:
			y //= -A[i][0]
			break
	z = x
	b = False
	for i in range(-5, 0):
		if A[i][1] == 1:
			z //= A[i][0]
			b = True
			break
	i = N - 6
	while i >= 0:
		if A[i][1] == 1:
			ans = max(ans, y * A[i][0])
			break
		i -= 1
	if b:
		i = N - 6
		while i >= 0:
			if A[i][1] == -1:
				ans = max(ans, -z * A[i][0])
				break
			i -= 1
	print(ans)


minn = -1e+18

def find(arr, n):
	(neg, pos) = ([], [])
	if n == 5:
		res = 1
		for x in arr:
			res = res * x
		return res
	for x in arr:
		if x < 0:
			neg.append(x)
		else:
			pos.append(x)
	sneg = sorted(neg)
	spos = sorted(pos)
	negl = len(neg)
	posl = len(pos)
	(p1, p2, p3, p4) = (minn, minn, minn, minn)
	if negl >= 2 and posl >= 3:
		p1 = sneg[0] * sneg[1] * spos[-1] * spos[-2] * spos[-3]
	if negl >= 4 and posl >= 1:
		p2 = sneg[0] * sneg[1] * sneg[2] * sneg[3] * spos[-1]
	if posl == 0:
		p3 = sneg[-1] * sneg[-2] * sneg[-3] * sneg[-4] * sneg[-5]
	if posl >= 5:
		p4 = spos[-1] * spos[-2] * spos[-3] * spos[-4] * spos[-5]
	return max([p1, p2, p3, p4])
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(find(arr, n))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	pos = neg = 0
	for num in arr:
		if num > 0:
			pos += 1
		elif num < 0:
			neg += 1
	ans = -float('inf')
	val = 1
	for i in range(1, 6):
		val *= arr[n - i]
	ans = max(ans, val)
	if neg >= 2 and pos >= 3:
		val = 1
		val = arr[0] * arr[1] * arr[n - 3] * arr[n - 2] * arr[n - 1]
		ans = max(ans, val)
	if neg >= 4 and pos >= 1:
		val = 1
		val = arr[0] * arr[1] * arr[2] * arr[3] * arr[n - 1]
		ans = max(ans, val)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	res = -10 ** 20
	for i in range(5):
		ans = 1
		for j in range(i):
			ans *= s[j]
		for j in range(5 - i):
			ans *= s[n - j - 1]
		res = max(res, ans)
	print(res)


def maxmulSubarrayOfSizeK(A, n, k):
	mul = 1
	if A[n - 1] == 0 and k & 1:
		return 0
	if A[n - 1] <= 0 and k & 1:
		for i in range(n - 1, n - k + 1, -1):
			mul *= A[i]
		return mul
	i = 0
	j = n - 1
	if k & 1:
		mul *= A[j]
		j -= 1
		k -= 1
	k >>= 1
	for itr in range(k):
		left_mul = A[i] * A[i + 1]
		right_mul = A[j] * A[j - 1]
		if left_mul > right_mul:
			mul *= left_mul
			i += 2
		else:
			mul *= right_mul
			j -= 2
	return mul
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ng = 0
	for i in a:
		if i < 0:
			ng += 1
	a.sort()
	if ng == n:
		ans = 1
		for i in range(n - 1, n - 6, -1):
			ans *= a[i]
		print(ans)
	else:
		print(maxmulSubarrayOfSizeK(a, n, 5))


t = int(input())

def prod(arr):
	ele = 1
	for ele2 in arr:
		ele = ele * ele2
	return ele
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	d = x[n - 5:n]
	rela = x[:5]
	jem = max(prod(d), prod(rela))
	for i in range(5):
		jem = max(prod(x[n - 5 + i:n] + x[:i]), jem)
	print(jem)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
from itertools import accumulate
from functools import lru_cache
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]

def giveanswer(l):
	ans = -float('inf')
	for i in range(6):
		ans = max(ans, l[i - 1] * l[i - 2] * l[i - 3] * l[i - 4] * l[i - 5])
	return ans
for _ in range(val()):
	n = val()
	print(giveanswer(sorted(li())))


import math
import sys
input = sys.stdin.readline
T = int(input())
for t in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	A = sorted(A, reverse=True)
	all_neg = len([el for el in A if el <= 0]) == N
	if all_neg:
		print(A[0] * A[1] * A[2] * A[3] * A[4])
	else:
		answer = -math.inf
		nb_neg = len([el for el in A if el < 0])
		if nb_neg >= 2:
			answer = max(answer, A[0] * A[1] * A[2] * A[-1] * A[-2])
		if nb_neg >= 4:
			answer = max(answer, A[0] * A[-1] * A[-2] * A[-3] * A[-4])
		answer = max(answer, A[0] * A[1] * A[2] * A[3] * A[4])
		print(answer)


t = int(input())
for test_cases in range(t):
	n = int(input())
	l = sorted([int(i) for i in input().split(' ')])
	if n == 5:
		print(l[0] * l[1] * l[2] * l[3] * l[4])
	elif l[-1] <= 0:
		print(l[-1] * l[-2] * l[-3] * l[-4] * l[-5])
	else:
		i = 0
		while l[i] < 0:
			i += 1
		p1 = l[-1]
		p2 = l[-2]
		p3 = l[-3]
		p4 = l[-4]
		p5 = l[-5]
		n1 = l[0]
		n2 = l[1]
		n3 = l[2]
		n4 = l[3]
		n5 = l[5]
		candidate1 = p1 * n1 * n2 * n3 * n4
		candidate2 = p1 * p2 * p3 * n1 * n2
		candidate3 = p1 * p2 * p3 * p4 * p5
		if n - i < 3:
			print(candidate1)
		elif n - i >= 3 and n - i < 5:
			print(max(candidate1, candidate2))
		else:
			print(max(candidate1, candidate2, candidate3))


n = int(input())
for i in range(n):
	k = int(input())
	a = list(map(int, input().split()))
	a.sort()
	p1 = a[0] * a[1] * a[2] * a[3] * a[-1]
	p2 = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	p3 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	print(max(p1, p2, p3))


from functools import reduce
t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	ans = reduce(lambda a, b: a * b, li[:5])
	ans = max(reduce(lambda a, b: a * b, li[:4] + li[-1:]), ans)
	ans = max(reduce(lambda a, b: a * b, li[:3] + li[-2:]), ans)
	ans = max(reduce(lambda a, b: a * b, li[:2] + li[-3:]), ans)
	ans = max(reduce(lambda a, b: a * b, li[:1] + li[-4:]), ans)
	ans = max(reduce(lambda a, b: a * b, li[:0] + li[-5:]), ans)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	if n == 5:
		pd = 1
		for i in a:
			pd = pd * i
		print(pd)
	else:
		a.sort()
		pd_l5 = a[0] * a[1] * a[2] * a[3] * a[4]
		pd_l4 = a[0] * a[1] * a[2] * a[3]
		pd_l3 = a[0] * a[1] * a[2]
		pd_l2 = a[0] * a[1]
		pd_l1 = a[0]
		pd_f5 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
		pd_f4 = a[-1] * a[-2] * a[-3] * a[-4]
		pd_f3 = a[-1] * a[-2] * a[-3]
		pd_f2 = a[-1] * a[-2]
		pd_f1 = a[-1]
		ans = max(pd_l5, pd_l4 * pd_f1, pd_l3 * pd_f2, pd_l2 * pd_f3, pd_l1 * pd_f4, pd_f5)
		print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input().split()
	nums = list(map(int, s))
	nums.sort()
	max1 = nums[0] * nums[1] * nums[-1] * nums[-2] * nums[-3]
	max2 = nums[0] * nums[1] * nums[2] * nums[3] * nums[-1]
	max3 = nums[-1] * nums[-2] * nums[-3] * nums[-4] * nums[-5]
	print(max(max1, max2, max3))


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	p = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	q = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	r = a[0] * a[1] * a[2] * a[3] * a[-1]
	print(max(p, q, r))
	t = t - 1


def mult(x):
	ans = 1
	for d in x:
		ans *= d
	return ans
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	arr1 = arr[::-1]
	ans = max([mult(arr1[:5]), mult(arr[:1]) * mult(arr1[:4]), mult(arr[:1]) * mult(arr1[:4]), mult(arr[:2]) * mult(arr1[:3]), mult(arr[:3]) * mult(arr1[:2]), mult(arr[:4]) * mult(arr1[:1]), mult(arr[:5])])
	print(ans)


for k in range(int(input())):
	n = int(input())
	t = list(map(int, input().split()))
	t.sort()
	u = t[0] * t[1] * t[2] * t[3] * t[-1]
	w = t[-1] * t[-2] * t[-3] * t[-4] * t[-5]
	v = t[-1] * t[-2] * t[-3] * t[-4] * t[0]
	r = t[-1] * t[-2] * t[-3] * t[0] * t[1]
	s = t[-1] * t[-2] * t[0] * t[1] * t[2]
	o = t[-1] * t[0] * t[1] * t[2] * t[3]
	print(max(v, u, w, r, s, o))


t = int(input())
for case in range(t):
	n = int(input())
	a = [int(s) for s in input().split(' ')]
	a.sort()
	x = []
	x.append(a[0] * a[1] * a[2] * a[3] * a[-1])
	x.append(a[0] * a[1] * a[-3] * a[-2] * a[-1])
	x.append(a[-5] * a[-4] * a[-3] * a[-2] * a[-1])
	print(max(x))


def prod(plop):
	thing = 1
	for x in plop:
		thing = thing * x
	return thing
t = int(input())
for _ in range(t):
	n = int(input())
	l1 = [int(x) for x in input().split()]
	ans = []
	for i in range(4):
		if i == 0:
			pos = sorted([x for x in l1 if x > 0])
			neg = sorted([x for x in l1 if x < 0])
		elif i == 1:
			pos.reverse()
		elif i == 2:
			neg.reverse()
		else:
			pos.reverse()
		for i in range(0, 6):
			pos_seg = pos[:i]
			j = 5 - i
			neg_seg = neg[:j]
			if len(pos_seg) + len(neg_seg) == 5:
				ans.append(prod(pos_seg) * prod(neg_seg))
			elif len(neg_seg) == 5:
				ans.append(prod(neg_seg))
			elif len(pos_seg) == 5:
				ans.append(prod(pos_seg))
	if 0 in l1:
		ans.append(0)
	print(max(ans))


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def prod(a):
	p = 1
	for i in a:
		p *= i
	return p
t = ii()
while t:
	t -= 1
	n = ii()
	a = li()
	a.sort(reverse=True)
	ch = 0
	if a[0] < 0:
		ch = 0
	elif a[-1] > 0:
		ch = n - 1
	else:
		while a[ch] > 0:
			ch += 1
	if ch == 0 or ch == n - 1 or n == 5:
		print(prod(a[0:5]))
	else:
		print(max(prod(a[0:5]), prod(a[0:3] + a[n - 2:]), prod([a[0]] + a[n - 4:])))


def sortval(n):
	return abs(n)
for _ in range(int(input())):
	__ = input()
	arr = list(map(int, input().split()))
	arr.sort()
	parr = [1, 1, 1, 1, 1, 1]
	parr[0] *= arr[0]
	parr[0] *= arr[1]
	parr[0] *= arr[2]
	parr[0] *= arr[3]
	parr[0] *= arr[4]
	parr[1] *= arr[0]
	parr[1] *= arr[1]
	parr[1] *= arr[2]
	parr[1] *= arr[3]
	parr[1] *= arr[-1]
	parr[2] *= arr[0]
	parr[2] *= arr[1]
	parr[2] *= arr[2]
	parr[2] *= arr[-2]
	parr[2] *= arr[-1]
	parr[3] *= arr[0]
	parr[3] *= arr[1]
	parr[3] *= arr[-3]
	parr[3] *= arr[-2]
	parr[3] *= arr[-1]
	parr[4] *= arr[0]
	parr[4] *= arr[-4]
	parr[4] *= arr[-3]
	parr[4] *= arr[-2]
	parr[4] *= arr[-1]
	parr[5] *= arr[-5]
	parr[5] *= arr[-4]
	parr[5] *= arr[-3]
	parr[5] *= arr[-2]
	parr[5] *= arr[-1]
	print(max(parr))


def solve(xs):
	xs = sorted(xs)
	a1 = xs[0] * xs[1] * xs[-3] * xs[-2] * xs[-1]
	a2 = xs[0] * xs[1] * xs[2] * xs[3] * xs[-1]
	a3 = xs[-5] * xs[-4] * xs[-3] * xs[-2] * xs[-1]
	return max((a1, a2, a3))
t = int(input())
for _ in range(t):
	_ = input()
	xs = [int(x) for x in input().split()]
	print(solve(xs))


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	n = int(sys.stdin.readline())
	list_num = list(map(int, sys.stdin.readline().split()))
	list_num.sort()
	res = -1000000000000000000
	list_check = []
	for i in range(5):
		list_check.append(list_num[i])
	for i in range(n - 1, n - 6, -1):
		if i <= 4:
			break
		list_check.append(list_num[i])
	n = len(list_check)
	for i in range(n):
		for j in range(i + 1, n):
			for k in range(j + 1, n):
				for l in range(k + 1, n):
					for t in range(l + 1, n):
						res = max(res, list_check[i] * list_check[j] * list_check[k] * list_check[l] * list_check[t])
	if res < 0 and list_num[-1] == 0:
		res = 0
	print(res)


for i in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	a = sorted(list1)
	neg_ans = a[-1] * a[-2] * a[-3] * a[0] * a[1]
	neg_ans1 = a[-1] * a[3] * a[2] * a[1] * a[0]
	pos_value = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	d = max(pos_value, neg_ans1, neg_ans)
	print(d)


for _ in range(int(input())):
	am = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	m = -999999999999999999999999999999999999999
	for i in range(am - 5, am + 1):
		mult = 1
		for g in range(5):
			mult *= arr[(g + i) % am]
		m = max(mult, m)
	print(m)


from sys import stdin
input = stdin.readline
T = int(input())
for t in range(1, T + 1):
	n = int(input())
	_input = list(map(int, input().split()))
	neg = []
	pos = []
	zero = False
	for i in _input:
		zero += i == 0
		if i > 0:
			pos.append(i)
		elif i < 0:
			neg.append(i)
	if len(neg) == 0:
		if len(pos) < 5:
			print(0)
		else:
			pos.sort(reverse=True)
			print(pos[0] * pos[1] * pos[2] * pos[3] * pos[4])
	elif len(pos) == 0:
		if zero:
			print(0)
		else:
			neg.sort(reverse=True)
			print(neg[0] * neg[1] * neg[2] * neg[3] * neg[4])
	else:
		ans = 1
		if len(pos) + len(neg) == 5:
			for i in pos:
				ans *= i
			for i in neg:
				ans *= i
			if zero and ans < 0:
				print(0)
			else:
				print(ans)
			continue
		one = two = three = four = five = 1
		pos.sort(reverse=True)
		neg.sort()
		for i in range(len(pos)):
			if i < 1:
				one = pos[i]
				three = five = one
			elif i < 3:
				three *= pos[i]
				five = three
			else:
				five *= pos[i]
			if i + 1 == 5:
				break
		for i in range(len(neg)):
			if i < 2:
				two *= neg[i]
				four = two
			else:
				four *= neg[i]
			if i + 1 == 4:
				break
		ans = -11111111111111
		if len(neg) >= 2 and len(pos) >= 3:
			ans = max(ans, two * three)
		if len(neg) >= 4 and len(pos) >= 1:
			ans = max(ans, one * four)
		if len(pos) >= 5:
			ans = max(ans, five)
		if ans < 0 and zero:
			ans = 0
		print(ans)


for _ in range(int(input())):
	ans = -2e+18
	n = int(input())
	l = 0
	r = n - 1
	v = list(map(int, input().split()))
	v.sort()
	for x in range(6):
		temp = 1
		for i in range(x):
			temp *= v[i]
		for i in range(5 - x):
			temp *= v[n - i - 1]
		ans = max(ans, temp)
	print(int(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	(po, ne) = (list(), list())
	l = list(map(int, input().split()))
	zer = False
	for c in l:
		if c > 0:
			po.append(c)
		elif c == 0:
			zer = True
		else:
			ne.append(c)
	po.sort(reverse=True)
	ne.sort()
	ans = list()
	if n == 5:
		print(l[0] * l[1] * l[2] * l[3] * l[4])
		continue
	if len(po) >= 5:
		ans.append(po[0] * po[1] * po[2] * po[3] * po[4])
	if len(po) >= 3 and len(ne) >= 2:
		ans.append(po[0] * po[1] * po[2] * ne[0] * ne[1])
	if len(po) >= 1 and len(ne) >= 4:
		ans.append(po[0] * ne[0] * ne[1] * ne[2] * ne[3])
	if len(ans) == 0:
		if zer == True:
			print(0)
		else:
			ne.reverse()
			print(ne[0] * ne[1] * ne[2] * ne[3] * ne[4])
	else:
		print(max(ans))


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
from itertools import permutations as permu

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
num = int(z())
for _ in range(num):
	n = int(z())
	arr = szzz()
	ans1 = 1
	for i in range(4):
		ans1 *= arr[i]
	ans1 *= arr[-1]
	ans2 = 1
	for i in range(1, 6):
		ans2 *= arr[-i]
	ans3 = 1
	for i in range(2):
		ans3 *= arr[i]
	for i in range(1, 4):
		ans3 *= arr[-i]
	print(max(ans1, ans2, ans3))


def maxProduct(arr, n):
	if n < 3:
		return -1
	arr.sort()
	return max(l[0] * l[1] * l[2] * l[3] * l[n - 1], l[n - 5] * l[n - 4] * l[n - 3] * l[n - 2] * l[n - 1], l[0] * l[1] * l[n - 3] * l[n - 2] * l[n - 1])
n = int(input())
for i in range(n):
	f = int(input())
	l = list(map(int, input().split()))[:f]
	print(maxProduct(l, f))


t = int(input())
while t != 0:
	n = int(input())
	s = input()
	arr = [int(ele) for ele in s.split()]
	arr.sort()
	if arr[-1] == 0:
		print(0)
	elif arr[-1] < 0:
		print(arr[-1] * arr[-2] * arr[-3] * arr[-4] * arr[-5])
	else:
		prod = arr[-1]
		arr.pop()
		for i in range(2):
			if arr[0] * arr[1] > arr[-1] * arr[-2]:
				prod *= arr[0] * arr[1]
				arr.pop(0)
				arr.pop(0)
			else:
				prod *= arr[-1] * arr[-2]
				arr.pop()
				arr.pop()
		print(prod)
	t -= 1


def prod(A, start, end):
	ans = 1
	for i in range(start, end + 1):
		ans *= A[i]
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	print(max(prod(A, 0, 4), prod(A, n - 5, n - 1), prod(A, 0, 1) * prod(A, n - 3, n - 1), prod(A, 0, 3) * prod(A, n - 1, n - 1)))


import sys
import math as mt
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 0
	(ch1, ch2, ch3) = (0, 0, 0)
	(neg2, neg4) = (-1, -1)
	if l[0] < 0 and l[1] < 0:
		cnt = 0
		mul = 1
		for i in range(n - 1, -1, -1):
			if l[i] >= 0:
				mul *= l[i]
				cnt += 1
			if cnt == 3:
				break
		if cnt == 3:
			ans1 = mul * l[0] * l[1]
			ch1 = 1
	if l[0] < 0 and l[1] < 0 and (l[2] < 0) and (l[3] < 0):
		cnt = 0
		mul = 1
		for i in range(n - 1, -1, -1):
			if l[i] >= 0:
				cnt += 1
				mul *= l[i]
				ch2 = 1
				break
		ans2 = l[0] * l[1] * l[2] * l[3] * mul
	mul = 1
	ans3 = 0
	l.sort(reverse=True)
	for i in range(5):
		mul *= l[i]
	ans3 = mul
	if ch1 == 1:
		ans3 = max(ans3, ans1)
	if ch2 == 1:
		ans3 = max(ans3, ans2)
	print(ans3)


import sys

def I():
	return int(sys.stdin.readline().rstrip())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))
t = I()
for i in range(t):
	n = I()
	A = LI()
	A.sort()
	a1 = A[-1] * A[-2] * A[-3] * A[-4] * A[-5]
	a2 = A[-1] * A[-2] * A[-3] * A[0] * A[1]
	a3 = A[-1] * A[0] * A[1] * A[2] * A[3]
	print(max(a1, a2, a3))


from sys import stdin, stdout
from collections import Counter
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	ans = 0
	a = list(map(int, stdin.readline().split()))
	a.sort()
	ans = float('-inf')
	all_neg = a[0] * a[1] * a[2] * a[3]
	all_pos = a[-1] * a[-2] * a[-3] * a[-4]
	pos2_neg2 = a[0] * a[1] * a[-1] * a[-2]
	for i in range(2, n - 2):
		ans = max(ans, pos2_neg2 * a[i])
	for i in range(4, n):
		ans = max(ans, all_neg * a[i])
	for i in range(n - 4):
		ans = max(ans, all_pos * a[i])
	print(ans)


mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	k = 5
	ls = list(map(int, input().split()))
	ls.sort()
	Max = ls[-1]
	if Max == 0 and k & 1:
		ans = 0
	elif Max < 0 and k & 1:
		ans = 1
		for i in range(n - k, n):
			ans = ans * ls[i]
	else:
		Count = ans = 1
		(i, j) = (0, n - 1)
		if k & 1:
			ans = ls[n - 1]
			j -= 1
			k -= 1
		while Count <= k // 2:
			if ls[i] * ls[i + 1] > ls[j] * ls[j - 1]:
				ans = ans * ls[i] * ls[i + 1]
				i += 2
			else:
				ans = ans * ls[j] * ls[j - 1]
				j -= 2
			Count += 1
	ans = ans
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	ans1 = 1
	for i in range(2):
		ans1 *= l[i]
	for j in range(n - 1, n - 4, -1):
		ans1 *= l[j]
	ans2 = 1
	for i in range(4):
		ans2 *= l[i]
	ans2 *= l[n - 1]
	ans3 = 1
	for j in range(n - 1, n - 6, -1):
		ans3 *= l[j]
	print(max(ans1, ans2, ans3))


import sys, os.path
import math
from collections import Counter
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	x = sorted(l, reverse=True)
	temp1 = x[0] * x[1] * x[2] * x[3] * x[4]
	temp2 = x[0] * x[1] * x[2] * x[-1] * x[-2]
	temp3 = x[0] * x[-1] * x[-2] * x[-3] * x[-4]
	ans = max(temp1, temp2)
	ans = max(ans, temp3)
	return ans
for _ in range(int(input())):
	print(solve())


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	ll = []
	for i in range(n):
		if l[i] < 0:
			ll.append((-l[i], 1, l[i]))
		else:
			ll.append((l[i], 0, l[i]))
	ll.sort(reverse=True)
	mul = 1
	pm = 10000000000000
	pmm = pm
	nm = -1000000000000
	for i in range(5):
		if ll[i][2] > 0:
			pm = min(pm, ll[i][2])
		if ll[i][2] < 0:
			nm = max(nm, ll[i][2])
		mul *= ll[i][2]
	mmul = mul
	lol = 0
	ans = mul
	for i in range(5, n):
		if ll[i][2] >= 0 and mul < 0:
			mmul = mul // nm
			mmul = mmul * ll[i][2]
			ans = max(ans, mmul)
		if ll[i][2] < 0 and pm != pmm:
			mmul = mul // pm
			mmul = mmul * ll[i][2]
			ans = max(ans, mmul)
	if ans < 0:
		cou = 0
		ans = 1
		for i in range(n - 1, -1, -1):
			ans = ans * ll[i][2]
			cou += 1
			if cou == 5:
				break
	print(ans)
	t -= 1


asda = int(input())
for asdsaaw in range(asda):
	n = int(input())
	p = input().split()
	for sd in range(n):
		p[sd] = int(p[sd])
	p.sort()
	multi = p[-5]
	for op in range(n - 4, n):
		multi = multi * p[op]
	mti = p[-1]
	for oi in range(4):
		mti = mti * p[oi]
	z = p[0] * p[1] * p[-3] * p[-2] * p[-1]
	m = [multi, z, mti]
	print(max(m))


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	pl = []
	mi = []
	for i in a:
		if i >= 0:
			pl.append(i)
		else:
			mi.append(i)
	pl.sort(reverse=True)
	mi.sort()
	li = min(5, len(pl), len(mi))
	ans = -1145141919810364364334334931
	for i in range(6):
		(al, be) = (i, 5 - i)
		aa = -1145141919810364364334334931
		if len(pl) >= al and len(mi) >= be:
			aa = 1
			for j in range(al):
				aa *= pl[j]
			for j in range(be):
				aa *= mi[j]
		ans = max(ans, aa)
	for i in range(6):
		(al, be) = (i, 5 - i)
		aa = -1145141919810364364334334931
		if len(pl) >= al and len(mi) >= be:
			aa = 1
			for j in range(al):
				aa *= pl[-j - 1]
			for j in range(be):
				aa *= mi[-j - 1]
		ans = max(ans, aa)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	x = []
	for i in a:
		if i:
			x.append(i)
	if len(x) < 5:
		print(0)
	else:
		x.sort()
		p = len(x) - 1
		l = []
		l.append(x[0] * x[1] * x[2] * x[3] * x[4])
		l.append(x[p - 0] * x[p - 1] * x[p - 2] * x[p - 3] * x[p - 4])
		l.append(x[0] * x[1] * x[2] * x[3] * x[p])
		l.append(x[0] * x[1] * x[2] * x[p - 1] * x[p])
		l.append(x[0] * x[1] * x[p - 2] * x[p - 1] * x[p])
		l.append(x[0] * x[p - 3] * x[p - 2] * x[p - 1] * x[p])
		if max(l) < 0 and len(x) < n:
			print(0)
		else:
			print(max(l))


import sys
import itertools
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		a = inlt()
		a.sort()
		if len(a) < 10:
			b = a
		else:
			b = a[:5] + a[-5:]
		res = a[0] * a[1] * a[2] * a[3] * a[4]
		for (i1, i2, i3, i4, i5) in itertools.combinations(b, 5):
			cur = i1 * i2 * i3 * i4 * i5
			if cur > res:
				res = cur
		print(res)
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = []
	temp = 1
	for i in range(n - 1, n - 6, -1):
		temp *= a[i]
	ans.append(temp)
	temp = 1
	for i in range(n - 1, n - 4, -1):
		temp *= a[i]
	temp *= a[0]
	temp *= a[1]
	ans.append(temp)
	temp = 1
	temp *= a[-1]
	temp *= a[0]
	temp *= a[1]
	temp *= a[2]
	temp *= a[3]
	ans.append(temp)
	print(max(ans))


import sys
input = sys.stdin.readline
import sys
import heapq
import copy
import math
import decimal

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	s = list(s[:len(s) - 1])
	s = [ord(s[i]) - ord('a') for i in range(len(s))]
	return s

def invr():
	return map(int, input().split())
ans = 0

def pr_list(a):
	print(*a, sep=' ')

def swap(a, b):
	temp = a
	a = b
	b = temp
	return [a, b]

def pri(a, b):
	s = '? ' + str(a) + ' ' + str(b)
	print(s)
	sys.stdout.flush()

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	hashm = {}
	arr = []
	heapq.heapify(arr)

	def find_next(hashm, itr):
		for i in range(itr, len(hashm)):
			if hashm[i] == 0:
				return i
	for test in range(tests):
		n = inp()
		arr = inlt()
		pos = [[0 for i in range(n)] for k in range(5)]
		neg = [[0 for i in range(n)] for k in range(5)]
		pos[0][0] = arr[0]
		neg[0][0] = arr[0]
		for i in range(1, n):
			pos[0][i] = max(arr[i], pos[0][i - 1])
			neg[0][i] = min(arr[i], neg[0][i - 1])
		for k in range(1, 5):
			pos[k][k] = max(arr[k] * pos[k - 1][k - 1], arr[k] * neg[k - 1][k - 1])
			neg[k][k] = min(arr[k] * pos[k - 1][k - 1], arr[k] * neg[k - 1][k - 1])
			for i in range(k + 1, n):
				pos[k][i] = max(pos[k][i - 1], arr[i] * pos[k - 1][i - 1], arr[i] * neg[k - 1][i - 1])
				neg[k][i] = min(neg[k][i - 1], arr[i] * pos[k - 1][i - 1], arr[i] * neg[k - 1][i - 1])
		ans = pos[4][4]
		for i in range(4, n):
			ans = max(ans, pos[4][i])
		print(ans)
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	plus = []
	minus = []
	for j in a:
		if j > 0:
			plus.append(j)
		elif j <= 0:
			minus.append(j)
	plus.sort()
	plus.reverse()
	minus.sort()
	ans = -1 * 10 ** 19
	check = [[0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]]
	for k in check:
		compare = 1
		if k[0] <= len(plus) and k[1] <= len(minus):
			for x in range(k[0]):
				compare *= plus[x]
			for y in range(k[1]):
				compare *= minus[y]
			if compare > ans:
				ans = compare
	if len(plus) == 0:
		minus.reverse()
		compare = 1
		for z in range(5):
			compare *= minus[z]
		if compare > ans:
			ans = compare
	if ans < 0 and 0 in a:
		ans = 0
	print(ans)


t = int(input())
for tc in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	pos = []
	neg = []
	for val in a:
		if val < 0:
			neg.append(val)
		else:
			pos.append(val)
	if neg == []:
		ans = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5]
	else:
		ans = max(a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5], a[0] * a[1] * a[n - 1] * a[n - 2] * a[n - 3], a[0] * a[1] * a[2] * a[3] * a[n - 1])
	print(ans)


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ans = -float('inf')
	ans = max(ans, a[0] * a[1] * a[2] * a[3] * a[4])
	ans = max(ans, a[0] * a[1] * a[2] * a[-1] * a[-2])
	ans = max(ans, a[0] * a[-1] * a[-2] * a[-3] * a[-4])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	nums = []
	for num in a:
		nums.append((abs(num), -1 if num < 0 else 1))
	nums.sort(key=lambda x: x[0], reverse=True)
	if all([num < 0 for num in a]):
		mult = -nums[-1][0] * nums[-2][0] * nums[-3][0] * nums[-4][0] * nums[-5][0]
		print(mult)
		continue
	mult = 1
	for i in range(5):
		mult *= nums[i][0] * nums[i][1]
	if mult < 0:
		mult1 = mult
		for i in range(5, len(nums)):
			if nums[i][1] > 0:
				mult *= nums[i][0]
				for j in range(4, -1, -1):
					if nums[j][1] < 0:
						mult = -mult // nums[j][0]
						break
				break
		for i in range(5, len(nums)):
			if nums[i][1] < 0:
				mult1 *= nums[i][0]
				for j in range(4, -1, -1):
					if nums[j][1] > 0:
						mult1 = -mult1 // nums[j][0]
						break
				break
		mult = max(mult, mult1)
	print(mult)


from sys import stdin, stdout
t = int(stdin.readline())
for case in range(t):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	xx = []
	(pos, neg) = (0, 0)
	for item in arr:
		if item >= 0:
			xx.append((item, 1))
			pos += 1
		else:
			xx.append((abs(item), -1))
			neg += 1
	xx.sort()
	ans = 1
	if pos == n:
		for pr in xx[-5:]:
			ans = ans * pr[0]
	elif neg == n:
		for pr in xx[:5]:
			ans = ans * pr[0] * pr[1]
	else:
		(posv, negv) = ([], [])
		for pr in xx[-5:]:
			ans = ans * pr[0] * pr[1]
			if pr[1] == -1:
				negv.append(pr[0] * pr[1])
			else:
				posv.append(pr[0])
		if ans < 0:
			(rxp, rxn) = ([], [])
			for pr in xx[:n - 5]:
				if pr[1] == 1:
					rxp.append(pr[0])
				else:
					rxn.append(pr[0] * pr[1])
			prv = ans
			if len(rxp) > 0 and len(negv) > 0:
				ans = max(ans, prv // max(negv) * max(rxp))
			if len(rxn) > 0 and len(posv) > 0:
				ans = max(ans, prv // min(posv) * min(rxn))
	stdout.write('{}\n'.format(ans))


def prod(A):
	p = 1
	for i in A:
		p *= i
	return p

def FirstPos(A):
	for i in range(len(A)):
		if A[i] > 0:
			return i
	return -1

def FirstNeg(A):
	for i in range(len(A)):
		if A[i] < 0:
			return i
	return -1
t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort(key=lambda x: abs(x), reverse=True)
	A_copy = A[:]
	B = A[:5]
	A = A[5:]
	Prod1 = prod(B)
	if Prod1 < 0:
		B = B[::-1]
		firstPosA = FirstPos(A)
		firstPosB = FirstPos(B)
		firstNegA = FirstNeg(A)
		firstNegB = FirstNeg(B)
		ans = [Prod1]
		if firstPosB != -1 and firstNegA != -1:
			ans.append(Prod1 * A[firstNegA] // B[firstPosB])
		if firstNegB != -1 and firstPosA != -1:
			ans.append(Prod1 * A[firstPosA] // B[firstNegB])
		if 0 in A:
			ans.append(0)
		if all(map(lambda x: x < 0, ans)):
			ans.append(prod(A_copy[-5:]))
		print(max(ans))
	else:
		print(Prod1)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = 0
	for i in l:
		if i == 0:
			f = 1
			break
	l.sort()
	m1 = l[n - 1] * l[n - 2] * l[n - 3] * l[n - 4] * l[n - 5]
	m1 = max(m1, l[0] * l[n - 1] * l[n - 2] * l[n - 3] * l[n - 4])
	m1 = max(m1, l[0] * l[1] * l[n - 1] * l[n - 2] * l[n - 3])
	m1 = max(m1, l[0] * l[1] * l[n - 1] * l[n - 2] * l[2])
	m1 = max(m1, l[0] * l[1] * l[n - 1] * l[3] * l[2])
	m1 = max(m1, l[0] * l[1] * l[4] * l[3] * l[2])
	if f:
		t = 0
		print(max(t, m1))
	else:
		print(m1)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	ans = -float('inf')
	for i in range(6):
		pos = i
		neg = 5 - i
		temp = 1
		for j in range(neg):
			temp *= A[j]
		for k in range(pos):
			l = n - 1 - k
			temp *= A[l]
		ans = max(temp, ans)
	print(ans)


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	pos = []
	neg = []
	zero = 0
	for a in A:
		if a > 0:
			pos.append(a)
		elif a < 0:
			neg.append(a)
		else:
			zero += 1
	pos.sort()
	neg.sort()
	ans = -float('inf')
	for i in range(6):
		if i > len(pos):
			continue
		for j in range(6 - i):
			if j > len(neg):
				continue
			for k in range(6 - i - j):
				if i + j + k != 5:
					continue
				if k > zero:
					continue
				tmp = 1
				if i:
					for p in pos[-i:]:
						tmp *= p
				if j:
					if j % 2:
						for n in neg[-j:]:
							tmp *= n
					else:
						for n in neg[:j]:
							tmp *= n
				if k:
					tmp = 0
				ans = max(ans, tmp)
	print(ans)


from itertools import combinations as permutations
import sys

def prod(A):
	return A[0] * A[1] * A[2] * A[3] * A[4]

def solve(A):
	A.sort()
	zero = False
	i_s = set([0, 1, 2, 3, 4])
	for x in range(len(A) - 5, len(A)):
		i_s.add(x)
	try:
		zindex = A.index(0)
		zero = True
	except:
		zindex = None
	if zindex is not None:
		for x in range(zindex + 1, zindex + 6):
			if x < len(A):
				i_s.add(x)
		for x in range(zindex - 5, zindex):
			if x > 0:
				i_s.add(x)
	l = []
	for i in i_s:
		l.append(A[i])
	perms = permutations(l, 5)
	largest = None
	for x in perms:
		p = prod(x)
		if largest == None:
			largest = p
		elif p > largest:
			largest = p
	if largest < 0 and zero == True:
		largest = 0
	return largest
s = sys.stdin.readlines()
for i in range(1, len(s)):
	if i % 2 == 0:
		A = s[i].split(' ')
		A = [int(a) for a in A]
		print(solve(A))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	pos = []
	neg = []
	for i in a:
		if i >= 0:
			pos.append(i)
		else:
			neg.append(i)
	pos.sort(reverse=True)
	neg.sort()
	x = pos[:5]
	y = neg[:5]
	l = x + y
	m = len(l)
	max = -100000000000000000000000000000000000
	for i in range(m):
		for j in range(i + 1, m):
			for k in range(j + 1, m):
				for o in range(k + 1, m):
					for p in range(o + 1, m):
						ans = l[i] * l[j] * l[k] * l[o] * l[p]
						if ans > max:
							max = ans
	if max < 0:
		m1 = len(pos)
		m2 = len(neg)
		if m1 == 0:
			ans = neg[-1] * neg[-5] * neg[-2] * neg[-3] * neg[-4]
		elif m1 == 2:
			ans = pos[-1] * pos[-2] * neg[-1] * neg[-2] * neg[-3]
		elif m1 == 4:
			ans = pos[-1] * pos[-2] * pos[-3] * pos[-4] * neg[-1]
		print(ans)
	else:
		print(max)


for _ in range(int(input())):
	n = int(input())
	c = list(map(int, input().split()))
	(a, b) = ([], [])
	for i in c:
		if i >= 0:
			a.append(i)
		else:
			b.append(-i)
	a.sort(reverse=True)
	b.sort(reverse=True)
	if n == 5:
		print(c[0] * c[1] * c[2] * c[3] * c[4])
	elif len(b) < 2:
		print(a[0] * a[1] * a[2] * a[3] * a[4])
	elif len(b) < 4:
		if len(a) < 5:
			print(a[0] * a[1] * a[2] * b[0] * b[1])
		elif b[0] * b[1] > a[3] * a[4]:
			print(a[0] * a[1] * a[2] * b[0] * b[1])
		else:
			print(a[0] * a[1] * a[2] * a[3] * a[4])
	else:
		x = b[0] * b[1]
		y = b[2] * b[3]
		if len(a) < 1:
			print(-b[-1] * b[-2] * b[-3] * b[-4] * b[-5])
		elif len(a) < 3:
			print(a[0] * x * y)
		elif len(a) < 5:
			print(max(x * y * a[0], x * a[0] * a[1] * a[2]))
		else:
			z = a[0] * a[1]
			p = a[2] * a[3]
			print(max(z * p * a[4], z * a[2] * x, x * y * a[0]))


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return (r, prime)

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	for j in range(ii()):
		n = ii()
		arr = li()
		arr = sorted(arr)
		max_ = -1e+26
		for i in range(6):
			p = 1
			p *= arr[(n - 5 + i) % n]
			p *= arr[(n - 4 + i) % n]
			p *= arr[(n - 3 + i) % n]
			p *= arr[(n - 2 + i) % n]
			p *= arr[(n - 1 + i) % n]
			if p > max_:
				max_ = p
		print(max_)
main()


from math import *
from bisect import *
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	a = LI()
	a.sort()
	y = 0
	z = False
	for i in range(n):
		if a[i] == 0:
			z = True
		elif a[i] > 0:
			y += 1
	if y == 0:
		if z:
			print(0)
		else:
			ans = 1
			for i in range(n - 1, n - 6, -1):
				ans *= a[i]
			print(ans)
	else:
		c = a[-1] * a[0] * a[1] * a[2] * a[3]
		d = a[-1] * a[-2] * a[-3] * a[0] * a[1]
		e = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
		print(max(c, d, e))


from functools import reduce
for t in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	if len(nums) == 5:
		re = reduce(int.__mul__, nums)
		print(re)
		continue
	nos = [nu for nu in nums if abs(nu) > 0]
	if len(nos) < 5:
		print(0)
		continue
	if all((nu <= 0 for nu in nums)):
		nums.sort(reverse=True)
		print(reduce(int.__mul__, nums[:5]))
		continue
	po = [n if n >= 0 else 0 for n in nums]
	ne = [n if n < 0 else 0 for n in nums]
	for i in range(1, 5):
		(ma, mi) = (0, 0)
		(nne, npo) = ([0] * i, [0] * i)
		for j in range(i):
			nu = nums[j]
			if po[j] > ma:
				ma = po[j]
			if ne[j] < mi:
				mi = ne[j]
		for j in range(i, n):
			nu = nums[j]
			if nu < 0:
				nne.append(ma * nu)
				npo.append(mi * nu)
			elif nu >= 0:
				npo.append(ma * nu)
				nne.append(mi * nu)
			if ne[j] < mi:
				mi = ne[j]
			if po[j] > ma:
				ma = po[j]
		po = npo
		ne = nne
	print(max(po))


for i in range(int(input())):
	n = int(input())
	a = [int(X) for X in input().split()]
	a.sort()
	x = []
	x.append(a[-1] * a[-2] * a[-3] * a[-4] * a[-5])
	x.append(a[-1] * a[-2] * a[-3] * a[0] * a[1])
	x.append(a[-1] * a[3] * a[2] * a[0] * a[1])
	print(max(x))


for _ in range(int(input())):
	n = int(input())
	arr = [int(j) for j in input().split()]
	arr.sort()
	temp = arr[:]
	max1 = max(temp)
	temp.remove(max1)
	max2 = max(temp)
	temp.remove(max2)
	max3 = max(temp)
	temp.remove(max3)
	max4 = max(temp)
	temp.remove(max4)
	max5 = max(temp)
	temp.remove(max5)
	ans = []
	ans.append(max1 * max2 * max3 * max4 * max5)
	temp = arr[:]
	min1 = min(temp)
	temp.remove(min1)
	min2 = min(temp)
	temp.remove(min2)
	min3 = min(temp)
	temp.remove(min3)
	min4 = min(temp)
	temp.remove(min4)
	min5 = min(temp)
	temp.remove(min5)
	ans.append(min1 * min2 * max1 * max2 * max3)
	ans.append(min1 * min2 * min3 * min4 * max1)
	ans.append(min1 * min2 * min3 * min4 * min5)
	res = max(ans)
	if res > 0:
		print(res)
	elif 0 in arr:
		print(0)
	else:
		print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	y = a[0] * a[1] * a[-1] * a[-2] * a[-3]
	z = a[0] * a[1] * a[2] * a[3] * a[-1]
	print(max(x, y, z))


from collections import deque as dq
from collections import defaultdict as dd
from collections import Counter as ct
from functools import lru_cache as lc
from heapq import heappush as hpush, heappop as hpop, heapify as hfy
from bisect import bisect_left, bisect_right
import itertools as it
import math
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	B = [a for a in A if a > 0]
	C = [a for a in A if a < 0]
	if len(B) + len(C) < 5:
		print(0)
		return
	B.sort(key=lambda x: -x)
	C.sort()
	ret = -float('inf')
	if 0 in A:
		ret = 0
	for m_cnt in range(6):
		p_cnt = 5 - m_cnt
		if p_cnt > len(B) or m_cnt > len(C):
			continue
		candi = 1
		for i in range(p_cnt):
			candi *= B[i]
		for i in range(m_cnt):
			candi *= C[i]
		ret = max(ret, candi)
		candi = 1
		for i in range(p_cnt):
			candi *= B[-i - 1]
		for i in range(m_cnt):
			candi *= C[-i - 1]
		ret = max(ret, candi)
	print(ret)
t = int(input())
for i in range(t):
	solve()


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 1000000007
for _ in range(vary(1)):
	n = vary(1)
	num = array_int()
	num.sort()
	ans = -10 ** 30
	if num[0] >= 0:
		print(num[n - 1] * num[n - 2] * num[n - 3] * num[n - 4] * num[n - 5])
	else:
		ans = max(ans, num[0] * num[1] * num[2] * num[3] * num[n - 1])
		ans = max(ans, num[n - 1] * num[n - 2] * num[n - 3] * num[0] * num[1])
		print(max(ans, num[n - 1] * num[n - 2] * num[n - 3] * num[n - 4] * num[n - 5]))


def prod(arr):
	ans = 1
	for i in range(len(arr)):
		ans *= arr[i]
	return ans
t = int(input())
for p in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	val = []
	arr1 = a[n - 5:n]
	val.append(prod(arr1))
	arr2 = a[0:1] + a[n - 4:n]
	val.append(prod(arr2))
	arr3 = a[0:2] + a[n - 3:n]
	val.append(prod(arr3))
	arr4 = a[0:3] + a[n - 2:n]
	val.append(prod(arr4))
	arr5 = a[0:4] + a[n - 1:n]
	val.append(prod(arr5))
	arr6 = a[0:5]
	val.append(prod(arr6))
	print(max(val))


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	negatives = []
	zero = 0
	positives = []
	for i in range(n):
		if a[i] < 0:
			negatives.append(a[i])
		if a[i] >= 0:
			positives.append(a[i])
	negatives.sort()
	positives.sort()
	if len(negatives) + len(positives) == 5:
		ans = 1
		for i in negatives:
			ans *= i
		for i in positives:
			ans *= i
		print(ans)
	elif len(positives) == 0:
		print(negatives[-1] * negatives[-2] * negatives[-3] * negatives[-4] * negatives[-5])
	elif len(positives) <= 2:
		print(negatives[0] * negatives[1] * negatives[2] * negatives[3] * positives[-1])
	elif len(positives) <= 4:
		if len(negatives) >= 4:
			print(max(negatives[0] * negatives[1] * negatives[2] * negatives[3] * positives[-1], negatives[0] * negatives[1] * positives[-2] * positives[-3] * positives[-1]))
		else:
			print(negatives[0] * negatives[1] * positives[-2] * positives[-3] * positives[-1])
	else:
		ans = positives[-1] * positives[-2] * positives[-3] * positives[-4] * positives[-5]
		if len(negatives) >= 4:
			ans = max(negatives[0] * negatives[1] * negatives[2] * negatives[3] * positives[-1], ans)
		if len(negatives) >= 2:
			ans = max(ans, negatives[0] * negatives[1] * positives[-2] * positives[-3] * positives[-1])
		print(ans)


for i in range(int(input())):
	n = int(input())
	mas = list(map(int, input().split()))
	mas.sort()
	ans1 = mas[-1] * mas[-2] * mas[-3] * mas[-4] * mas[-5]
	ans2 = mas[-1] * mas[-2] * mas[-3] * mas[-4] * mas[0]
	ans3 = mas[-1] * mas[-2] * mas[-3] * mas[0] * mas[1]
	ans4 = mas[-1] * mas[-2] * mas[0] * mas[1] * mas[2]
	ans5 = mas[-1] * mas[0] * mas[1] * mas[2] * mas[3]
	ans6 = mas[0] * mas[1] * mas[2] * mas[3] * mas[4]
	print(max(ans1, ans2, ans3, ans4, ans5, ans6))


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	out1 = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	out2 = a[-1] * a[-2] * a[-3] * a[0] * a[1]
	out3 = a[-1] * a[0] * a[1] * a[2] * a[3]
	print(max(out1, out2, out3))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	pos = []
	neg = []
	for i in a:
		if i >= 0:
			pos.append(i)
		else:
			neg.append(i)
	pos = sorted(pos, reverse=True)
	neg = sorted(neg)
	posLen = len(pos)
	negLen = len(neg)
	if posLen > 0:
		ans = pos.pop(0)
		posLen -= 1
		for i in range(2):
			if posLen < 2 or negLen < 2:
				if negLen >= 2:
					ans *= neg.pop(0) * neg.pop(0)
					negLen -= 2
				elif posLen >= 2:
					ans *= pos.pop(0) * pos.pop(0)
					posLen -= 2
				else:
					ans *= pos.pop(0) * neg.pop(0)
			elif pos[0] * pos[1] >= neg[0] * neg[1]:
				ans *= pos.pop(0) * pos.pop(0)
				posLen -= 2
			else:
				ans *= neg.pop(0) * neg.pop(0)
				negLen -= 2
	else:
		ans = neg[-1] * neg[-2] * neg[-3] * neg[-4] * neg[-5]
	print(ans)


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
for _ in range(II()):
	n = II()
	aa = LI()
	pos = []
	neg = []
	for a in aa:
		if a < 0:
			neg.append(a)
		else:
			pos.append(a)
	neg.sort()
	pos.sort(reverse=True)
	aa.sort(key=lambda x: abs(x))
	ans = 1
	for a in aa[:5]:
		ans *= a
	if len(pos) > 4:
		cur = 1
		for a in pos[:5]:
			cur *= a
		ans = max(ans, cur)
	if len(neg) > 1 and len(pos) > 2:
		cur = 1
		for a in neg[:2] + pos[:3]:
			cur *= a
		ans = max(ans, cur)
	if len(neg) > 3 and len(pos) > 0:
		cur = 1
		for a in neg[:4] + pos[:1]:
			cur *= a
		ans = max(ans, cur)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [-9999999999999999999999999999999999] + [int(i) for i in input().split()]
	a.sort()
	t = a[1] * a[2] * a[3] * a[4] * a[5]
	t1 = a[1] * a[2] * a[3] * a[4] * a[n]
	t2 = a[1] * a[2] * a[3] * a[n - 1] * a[n]
	t3 = a[1] * a[2] * a[n - 2] * a[n - 1] * a[n]
	t4 = a[1] * a[n - 3] * a[n - 2] * a[n - 1] * a[n]
	t5 = a[n - 4] * a[n - 3] * a[n - 2] * a[n - 1] * a[n]
	print(max(t, t1, t2, t3, t4, t5))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = []
	p = []
	cnt0 = 0
	for val in a:
		if val > 0:
			p.append(val)
		elif val < 0:
			m.append(val)
		else:
			cnt0 += 1
	p = sorted(p, reverse=True)
	m = sorted(m)
	ans = -10 ** 20
	tmp = 1
	if len(p) >= 5:
		for i in range(5):
			tmp *= p[i]
		ans = max(tmp, ans)
	tmp = 1
	if len(p) >= 4 and len(m) >= 1:
		for i in range(4):
			tmp *= p[~i]
		for i in range(1):
			tmp *= m[~i]
		ans = max(tmp, ans)
	tmp = 1
	if len(p) >= 3 and len(m) >= 2:
		for i in range(3):
			tmp *= p[i]
		for i in range(2):
			tmp *= m[i]
		ans = max(tmp, ans)
	tmp = 1
	if len(p) >= 2 and len(m) >= 3:
		for i in range(2):
			tmp *= p[~i]
		for i in range(3):
			tmp *= m[~i]
		ans = max(tmp, ans)
	tmp = 1
	if len(p) >= 1 and len(m) >= 4:
		for i in range(1):
			tmp *= p[i]
		for i in range(4):
			tmp *= m[i]
		ans = max(tmp, ans)
	tmp = 1
	if len(m) >= 5:
		for i in range(5):
			tmp *= m[~i]
		ans = max(tmp, ans)
	if cnt0 > 0:
		ans = max(0, ans)
	print(ans)


import itertools
from functools import reduce
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	pos = reduce(lambda acc, cur: acc + int(cur > 0), a, 0)
	a.sort()
	if n > 10:
		a = a[:5] + a[-5:]
	res = -pow(10, 25)
	for comb in itertools.combinations(a, 5):
		r = 1
		for i in comb:
			r = r * i
		res = max(r, res)
	print(res)


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	ans = l[0] * l[1] * l[2] * l[3] * l[4]
	for i in range(6):
		curr = 1
		for j in range(i):
			curr *= l[j]
		for j in range(-1, i - 5 - 1, -1):
			curr *= l[j]
		ans = max(ans, curr)
	print(ans)


from functools import reduce
t = int(input())
for i in range(t):
	n = input()
	a = list(map(int, input().split()))
	if len(a) == 5:
		print(reduce(lambda x, y: x * y, a))
	else:
		a.sort()
		a_copy = a.copy()
		a_copy.reverse()
		a1 = reduce(lambda x, y: x * y, a_copy[:5])
		a2 = reduce(lambda x, y: x * y, a[:5])
		a3 = reduce(lambda x, y: x * y, a[:4]) * a[len(a) - 1]
		a4 = reduce(lambda x, y: x * y, a[:2]) * reduce(lambda x, y: x * y, a_copy[:3])
		print(max(max(a1, a2), max(a4, a3)))


t = int(input())
for _ in range(t):
	n = int(input())
	l = input().split()
	mult = 1
	if n == 5:
		for i in l:
			mult *= int(i)
		print(mult)
	else:
		mult = [1, 1, 1]
		l = sorted(l, key=lambda x: int(x), reverse=True)
		mult[0] = int(l[0])
		mult[1] = mult[0] * int(l[1]) * int(l[2])
		mult[2] = mult[1] * int(l[3]) * int(l[4])
		mult[1] = mult[1] * int(l[-1]) * int(l[-2])
		mult[0] = mult[0] * int(l[-1]) * int(l[-2]) * int(l[-3]) * int(l[-4])
		max = mult[0]
		for m in mult:
			if max < m:
				max = m
		print(max)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	neg = []
	pos = []
	z = 0
	for i in a:
		if i > 0:
			pos.append(i)
		elif i == 0:
			z += 1
		else:
			neg.append(i)
	pos.sort(reverse=True)
	neg.sort()
	if z > 0:
		ans = 0
	else:
		ans = -float('inf')
	lp = len(pos)
	ln = len(neg)
	if 5 <= lp:
		c = 1
		for i in range(5):
			c *= pos[i]
		ans = max(ans, c)
	if 3 <= lp and 2 <= ln:
		c = 1
		for i in range(3):
			c *= pos[i]
		for i in range(2):
			c *= neg[i]
		ans = max(ans, c)
	if 1 <= lp and 4 <= ln:
		c = 1
		for i in range(1):
			c *= pos[i]
		for i in range(4):
			c *= neg[i]
		ans = max(ans, c)
	if 4 <= lp and 1 <= ln:
		c = 1
		for i in range(lp - 1, lp - 1 - 4, -1):
			c *= pos[i]
		for i in range(ln - 1, ln - 1 - 1, -1):
			c *= neg[i]
		ans = max(ans, c)
	if 2 <= lp and 3 <= ln:
		c = 1
		for i in range(lp - 1, lp - 1 - 2, -1):
			c *= pos[i]
		for i in range(ln - 1, ln - 1 - 3, -1):
			c *= neg[i]
		ans = max(ans, c)
	if 5 <= ln:
		c = 1
		for i in range(ln - 1, ln - 1 - 5, -1):
			c *= neg[i]
		ans = max(ans, c)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 1
	if l[0] >= 0 or (l[0] < 0 and l[1] >= 0) or l[-1] <= 0:
		for i in range(n - 1, n - 6, -1):
			ans *= l[i]
	else:
		if l[0] * l[1] >= l[n - 1] * l[n - 2]:
			ans *= l[0] * l[1]
			if l[2] * l[3] >= l[n - 1] * l[n - 2] or l[n - 3] < 0:
				ans *= l[2] * l[3] * l[n - 1]
			else:
				ans *= l[n - 1] * l[n - 2] * l[n - 3]
		else:
			ans *= l[n - 1] * l[n - 2]
			if l[0] * l[1] >= l[n - 3] * l[n - 4] or l[n - 5] < 0:
				ans *= l[0] * l[1] * l[n - 3]
			else:
				ans *= l[n - 3] * l[n - 4] * l[n - 5]
		a2 = l[0] * l[1] * l[n - 3] * l[n - 2] * l[n - 1]
		ans = max(a2, ans)
		a1 = l[0] * l[1] * l[2] * l[3] * l[n - 1]
		ans = max(ans, a1)
	print(ans)


import functools
import operator
t = int(input())
foldr = lambda func, acc, xs: functools.reduce(lambda x, y: func(y, x), xs[::-1], acc)
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	positive = sorted(filter(lambda x: x >= 0, a))
	negative = sorted(filter(lambda x: x < 0, a), reverse=True)
	result = foldr(operator.mul, 1, a[:5])
	i = 0
	if len(positive) >= 5:
		result = max(result, foldr(operator.mul, 1, positive[-5:]))
	if len(positive) >= 3 and len(negative) >= 2:
		result = max(result, foldr(operator.mul, 1, positive[-3:] + negative[-2:]))
	if len(positive) >= 1 and len(negative) >= 4:
		result = max(result, foldr(operator.mul, 1, positive[-1:] + negative[-4:]))
	if len(positive) >= 2 and len(negative) >= 3:
		result = max(result, foldr(operator.mul, 1, positive[:2] + negative[:3]))
	if len(positive) >= 4 and len(negative) >= 1:
		result = max(result, foldr(operator.mul, 1, positive[:4] + negative[:1]))
	if len(negative) >= 5:
		result = max(result, foldr(operator.mul, 1, negative[:5]))
	print(result)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]

def solve():
	n = Scanner.int()
	a = Scanner.map_int()
	(A, C) = ([], [])
	zero = False
	for i in a:
		if i < 0:
			A.append(i)
		elif i == 0:
			zero = True
		else:
			C.append(i)
	A.sort()
	C.sort(reverse=True)
	ans = -1000000000000000000
	if len(A) >= 5:
		ans = max(ans, A[-1] * A[-2] * A[-3] * A[-4] * A[-5])
	if len(A) >= 4 and len(C) >= 1:
		ans = max(ans, A[0] * A[1] * A[2] * A[3] * C[0])
	if len(A) >= 3 and len(C) >= 2:
		ans = max(ans, A[-1] * A[-2] * A[-3] * C[0] * C[1])
	if len(A) >= 2 and len(C) >= 3:
		ans = max(ans, A[0] * A[1] * C[0] * C[1] * C[2])
	if len(A) >= 1 and len(C) >= 4:
		ans = max(ans, A[-1] * C[0] * C[1] * C[2] * C[3])
	if len(C) >= 5:
		ans = max(ans, C[0] * C[1] * C[2] * C[3] * C[4])
	if ans < 0 and zero:
		ans = 0
	print(ans)

def main():
	T = Scanner.int()
	for _ in range(T):
		solve()
main()


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	x = []
	for elem in a:
		if elem:
			x.append(elem)
	if len(x) < 5:
		print(0)
	else:
		x.sort()
		p = len(x) - 1
		lst = []
		lst.append(x[0] * x[1] * x[2] * x[3] * x[4])
		lst.append(x[p - 0] * x[p - 1] * x[p - 2] * x[p - 3] * x[p - 4])
		lst.append(x[0] * x[1] * x[2] * x[3] * x[p])
		lst.append(x[0] * x[1] * x[2] * x[p - 1] * x[p])
		lst.append(x[0] * x[1] * x[p - 2] * x[p - 1] * x[p])
		lst.append(x[0] * x[p - 3] * x[p - 2] * x[p - 1] * x[p])
		print(0 if max(lst) < 0 and len(x) < n else max(lst))


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	if a[-1] > 0:
		n4 = 1
		n2 = 1
		p1 = a[-1]
		p3 = 1
		p5 = 1
		for i in range(2):
			n2 *= a[i]
		for i in range(4):
			n4 *= a[i]
		a.reverse()
		for i in range(3):
			p3 *= a[i]
		for i in range(5):
			p5 *= a[i]
		print(max(n4 * p1, n2 * p3, p5))
	else:
		print(a[-1] * a[-2] * a[-3] * a[-4] * a[-5])


for _ in range(int(input())):
	k = int(input())
	a = list(map(int, input().split()))
	co = 0
	a.sort()
	for elem in a:
		if elem < 0:
			co += 1
		if elem > 0:
			break
		if co > 4:
			break
	if co == 1 or co == 0:
		prod = a[-1] * a[-2] * a[-3] * a[-4] * a[-5]
	elif co == 2 or co == 3:
		prod = max(a[-1] * a[-2] * a[-3] * a[-4] * a[-5], a[-1] * a[-2] * a[-3] * a[0] * a[1])
	else:
		prod = max(a[-1] * a[-2] * a[-3] * a[-4] * a[-5], a[-1] * a[-2] * a[-3] * a[0] * a[1], a[-1] * a[2] * a[3] * a[0] * a[1])
	print(prod)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = a[0] * a[1] * a[2] * a[3] * a[4]
	for i in range(6):
		b = 1
		for j in range(n + i - 5, n + i):
			b *= a[j % n]
		ans = max(ans, b)
	print(ans)


k = [[0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]]
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(lst, lst1) = ([], [])
	for i in a:
		if i < 0:
			lst.append(i)
		elif i >= 0:
			lst1.append(abs(i))
	lst.sort(reverse=True)
	lst1.sort(reverse=True)
	lst = lst + lst1
	p = []
	for i in range(len(lst) - 4):
		count = 1
		for j in lst[i:i + 5]:
			count *= j
		p.append(count)
	if p == []:
		count = 1
		for i in range(5):
			count *= lst[i]
		print(count)
	else:
		print(max(p))


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = -10 ** 100
	if n == 5:
		ans = l[0] * l[1] * l[2] * l[3] * l[4]
	elif n == 6:
		if 0 not in l:
			prod = l[0] * l[1] * l[2] * l[3] * l[4] * l[5]
			ans = max(prod / l[0], prod / l[1], prod / l[2], prod / l[3], prod / l[4], prod / l[5])
	elif n == 7:
		if 0 not in l:
			prod = l[0] * l[1] * l[2] * l[3] * l[4] * l[5] * l[6]
			ans = max(prod / l[0] / l[1], prod / l[0] / l[2], prod / l[0] / l[3], prod / l[0] / l[4], prod / l[0] / l[5], prod / l[0] / l[6], prod / l[1] / l[2], prod / l[1] / l[3], prod / l[1] / l[4], prod / l[1] / l[5], prod / l[1] / l[6], prod / l[2] / l[3], prod / l[2] / l[4], prod / l[2] / l[5], prod / l[2] / l[6], prod / l[3] / l[4], prod / l[3] / l[5], prod / l[3] / l[6], prod / l[4] / l[5], prod / l[4] / l[6], prod / l[5] / l[6])
	mp = []
	mn = []
	for i in l:
		if i > 0:
			mp.append(i)
		if i < 0:
			mn.append(i)
	if 0 in l:
		ans = 0
	mp = list(sorted(mp))
	mn = list(sorted(mn))
	if len(mp) >= 5:
		ans = max(ans, mp[-1] * mp[-2] * mp[-3] * mp[-4] * mp[-5])
	if len(mp) >= 3 and len(mn) >= 2:
		ans = max(ans, mp[-1] * mp[-2] * mp[-3] * mn[0] * mn[1])
	if len(mp) >= 1 and len(mn) >= 4:
		ans = max(ans, mp[-1] * mn[0] * mn[1] * mn[2] * mn[3])
	if len(mp) == 0 and len(mn) >= 5:
		ans = max(ans, mn[-1] * mn[-2] * mn[-3] * mn[-4] * mn[-5])
	print(int(ans))


t = int(input())
for tt in range(t):
	n = int(input())
	numbers = [int(x) for x in input().split()]
	N = []
	P = []
	Z = False
	for x in numbers:
		if x > 0:
			P.append(x)
		elif x < 0:
			N.append(x)
		else:
			Z = True
	P.sort()
	N.sort()
	ans = -10 ** 18
	if Z:
		ans = max(ans, 0)
	if len(P) >= 5:
		ans = max(ans, P[-5] * P[-4] * P[-3] * P[-2] * P[-1])
	if len(P) >= 4 and len(N) >= 1:
		ans = max(ans, N[-1] * P[0] * P[1] * P[2] * P[3])
	if len(P) >= 3 and len(N) >= 2:
		ans = max(ans, P[-3] * P[-2] * P[-1] * N[0] * N[1])
	if len(P) >= 2 and len(N) >= 3:
		ans = max(ans, N[-3] * N[-2] * N[-1] * P[0] * P[1])
	if len(P) >= 1 and len(N) >= 4:
		ans = max(ans, P[-1] * N[0] * N[1] * N[2] * N[3])
	if len(N) >= 5:
		ans = max(ans, N[-5] * N[-4] * N[-3] * N[-2] * N[-1])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	ng = 0
	pg = 0
	c = 1
	for num in lis:
		if num < 0:
			ng = ng + 1
		else:
			pg = pg + 1
	mult = 1
	if pg == 0:
		print(lis[n - 1] * lis[n - 2] * lis[n - 3] * lis[n - 4] * lis[n - 5])
	elif pg == 1:
		for j in range(4):
			mult = mult * lis[j]
		mult = mult * lis[n - 1]
		print(mult)
	elif pg == 2 and ng == 3:
		for j in range(5):
			mult = mult * lis[j]
		print(mult)
	elif pg == 2 and ng >= 4:
		k1 = 1
		for j in range(4):
			k1 = k1 * lis[j]
		k1 = k1 * lis[n - 1]
		print(k1)
	elif pg == 3 and ng < 4:
		k1 = 1
		for j in range(2):
			k1 = k1 * lis[j]
		k1 = k1 * lis[n - 1] * lis[n - 2] * lis[n - 3]
		print(k1)
	elif pg == 3 and ng >= 4:
		k1 = 1
		k2 = 1
		for j in range(4):
			k1 = k1 * lis[j]
		k1 = k1 * lis[n - 1]
		for j in range(2):
			k2 = k2 * lis[j]
		k2 = k2 * lis[n - 1] * lis[n - 2] * lis[n - 3]
		print(max(k1, k2))
	elif pg == 4 and ng == 1:
		for j in range(5):
			mult = mult * lis[j]
		print(mult)
	elif pg == 4 and (ng == 2 or ng == 3):
		k2 = 1
		for j in range(2):
			k2 = k2 * lis[j]
		k2 = k2 * lis[n - 1] * lis[n - 2] * lis[n - 3]
		print(k2)
	elif pg == 4 and ng >= 4:
		k1 = 1
		k2 = 1
		for j in range(4):
			k1 = k1 * lis[j]
		k1 = k1 * lis[n - 1]
		for j in range(2):
			k2 = k2 * lis[j]
		k2 = k2 * lis[n - 1] * lis[n - 2] * lis[n - 3]
		print(max(k1, k2))
	elif pg >= 5 and ng >= 2:
		k1 = 1
		k2 = 1
		k3 = lis[n - 1] * lis[n - 2] * lis[n - 3] * lis[n - 4] * lis[n - 5]
		for j in range(4):
			k1 = k1 * lis[j]
		k1 = k1 * lis[n - 1]
		for j in range(2):
			k2 = k2 * lis[j]
		k2 = k2 * lis[n - 1] * lis[n - 2] * lis[n - 3]
		print(max(k1, k2, k3))
	else:
		print(lis[n - 1] * lis[n - 2] * lis[n - 3] * lis[n - 4] * lis[n - 5])


for i in [*open(0)][2::2]:
	a = sorted(map(int, i.split()))
	print(max(a[-1] * a[-2] * a[-3] * a[-4] * a[-5], a[-1] * a[-2] * a[-3] * a[1] * a[0], a[-1] * a[3] * a[2] * a[1] * a[0]))


import sys
from collections import defaultdict, deque
sys.setrecursionlimit(10 ** 6)

def prod(nums):
	product = 1
	for x in nums:
		product *= x
	return product
n = int(input())
for _ in range(n):
	k = input()
	nums = list(map(int, input().split()))
	nums.sort()
	take5 = prod(nums[-5:])
	take3 = prod(nums[-3:] + nums[:2])
	take1 = prod(nums[-1:] + nums[:4])
	maximum = max(take5, take3, take1)
	print(maximum)


for _ in range(int(input())):
	n = int(input())
	data = list(map(int, input().split()))
	result = -1e+21
	if 0 in data:
		result = 0
	negative_count = 0
	positive_count = 0
	positive_list = []
	negative_list = []
	for x in data:
		if x < 0:
			negative_list.append(x)
		elif x > 0:
			positive_list.append(x)
	data.sort()
	negative_list.sort()
	positive_list.sort()
	if len(negative_list) >= 4 and len(positive_list) >= 1:
		result = max(result, negative_list[0] * negative_list[1] * negative_list[2] * negative_list[3] * positive_list[-1])
	if len(negative_list) >= 2 and len(positive_list) >= 3:
		result = max(result, negative_list[0] * negative_list[1] * positive_list[-1] * positive_list[-2] * positive_list[-3])
	if len(negative_list) >= 0 and len(positive_list) >= 5:
		result = max(result, positive_list[-1] * positive_list[-2] * positive_list[-3] * positive_list[-4] * positive_list[-5])
	if len(negative_list) >= 1 and len(positive_list) >= 4:
		result = max(result, negative_list[-1] * positive_list[0] * positive_list[1] * positive_list[2] * positive_list[3])
	if len(negative_list) >= 3 and len(positive_list) >= 2:
		result = max(result, negative_list[-1] * negative_list[-2] * negative_list[-3] * positive_list[0] * positive_list[1])
	if len(negative_list) >= 5 and len(positive_list) >= 0:
		result = max(result, negative_list[-1] * negative_list[-2] * negative_list[-3] * negative_list[-4] * negative_list[-5])
	print(result)


t = int(input())
for j in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	d = [0, 1, 2, 3, 4]
	res1 = -1000000000000000000
	for i in range(0, -6, -1):
		res = 1
		for j in d:
			res *= a[j + i]
		res1 = max(res, res1)
	print(res1)


K = 5

def solve(n, a):
	neg = []
	pos = []
	hasZero = False
	for v in a:
		if v < 0:
			neg.append(-v)
		elif v > 0:
			pos.append(v)
		else:
			hasZero = True
	pos.sort()
	neg.sort()
	negRes = True
	for i in range(0, K + 1, 2):
		if len(pos) >= K - i and len(neg) >= i:
			negRes = False
			break
	if negRes:
		if hasZero:
			return 0
		i = 0
		j = 0
		ans = -1
		need = K
		while need > 0 and i < len(pos) and (j < len(neg)):
			if pos[i] < neg[j]:
				ans *= pos[i]
				i += 1
			else:
				ans *= neg[j]
				j += 1
			need -= 1
		while need > 0 and i < len(pos):
			need -= 1
			ans *= pos[i]
			i += 1
		while need > 0 and j < len(neg):
			need -= 1
			ans *= neg[j]
			j += 1
		return ans
	if len(pos) + len(neg) < K:
		return 0
	pos.reverse()
	neg.reverse()
	best = 1
	for i in range(K):
		best *= a[i]
	for i in range(0, K + 1, 2):
		if len(neg) < i or len(pos) < K - i:
			continue
		t = 1
		for z in range(i):
			t *= neg[z]
		for z in range(K - i):
			t *= pos[z]
		best = max(best, t)
	return best
tests = int(input())
for test in range(tests):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(n, a))


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	n = get_int()
	ls = get_list()
	ls.sort()

	def calculate_prod(ls, i, j):
		prod = 1
		while i <= j:
			prod *= ls[i]
			i += 1
		return prod
	ans = max(calculate_prod(ls, 0, 4), calculate_prod(ls, -5, -1), calculate_prod(ls, 0, 3) * calculate_prod(ls, -1, -1))
	ans = max(ans, calculate_prod(ls, 0, 2) * calculate_prod(ls, -2, -1), calculate_prod(ls, 0, 1) * calculate_prod(ls, -3, -1), calculate_prod(ls, 0, 0) * calculate_prod(ls, -4, -1))
	print(ans)

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


import math
t = int(input())
while t > 0:
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	ans1 = 1
	for i in arr[len(arr) - 5:len(arr)]:
		ans1 *= i
	ans2 = 1
	for i in arr[:2]:
		ans2 *= i
	for i in arr[len(arr) - 3:len(arr)]:
		ans2 *= i
	ans3 = arr[-1]
	for i in arr[:4]:
		ans3 *= i
	max1 = max(ans1, ans2, ans3)
	print(max1)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	i = 0
	sum1 = 1
	sum2 = 1
	final = a[0] * a[1] * a[2] * a[3] * a[4]
	if len(a) == 5:
		print(final)
	else:
		while i < 5:
			for k in range(i):
				sum1 = sum1 * a[k]
			for l in range(n - 1, n - (5 - i) - 1, -1):
				sum2 = sum2 * a[l]
			total = sum1 * sum2
			if total > final:
				final = total
			i += 1
			sum1 = 1
			sum2 = 1
		print(final)


from collections import Counter
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()

def getProduct(arr):
	if len(arr) == 0:
		return 1
	ans = 1
	for v in arr:
		ans *= v
	return ans
for _ in range(t):
	gil()
	a = gil()
	a.sort()
	ans = -inf
	for i in [0, 2, 4]:
		ans = max(ans, getProduct(a[:i]) * getProduct(a[-(5 - i):]))
	print(ans)


import sys
readline = sys.stdin.readline
INF = 1 << 60

def read_int():
	return int(readline())

def read_int_n():
	return list(map(int, readline().split()))

def read_float():
	return float(readline())

def read_float_n():
	return list(map(float, readline().split()))

def read_str():
	return readline().strip()

def read_str_n():
	return readline().strip().split()

def ep(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.perf_counter()
		ret = f(*args, **kwargs)
		e = time.perf_counter()
		ep(e - s, 'sec')
		return ret
	return wrap
from collections import Counter
from functools import reduce
from operator import mul

def slv(N, A):
	na = [a for a in A if a < 0]
	pa = [a for a in A if a >= 0]
	na.sort()
	pa.sort()
	ans = -INF
	for n in range(5 + 1):
		p = 5 - n
		if len(na) < n:
			continue
		if len(pa) < p:
			continue
		ans = max(ans, reduce(mul, na[:n] + pa[:p], 1))
		ans = max(ans, reduce(mul, na[:n] + pa[len(pa) - p:], 1))
		ans = max(ans, reduce(mul, na[len(na) - n:] + pa[:p], 1))
		ans = max(ans, reduce(mul, na[len(na) - n:] + pa[len(pa) - p:], 1))
	return ans

def main():
	for _ in range(read_int()):
		N = read_int()
		A = read_int_n()
		print(slv(N, A))
main()


from itertools import combinations

def pol(a):
	x = []
	p = -1
	for (i, row) in enumerate(a):
		if row >= 0:
			p = i
	if p == -1:
		return a[::-1][:5]
	i = 0
	for (c, row) in enumerate(a):
		if c < p - 4 and i < 5:
			x.append(row)
			i += 1
		elif p - 5 < c < p + 5:
			x.append(row)
		elif c >= len(a) - 6:
			x.append(row)
	return x
for _ in range(int(input())):
	(n, a) = (int(input()), sorted([int(x) for x in input().split()]))
	x = []
	for (i, j, k, l, t) in combinations(pol(a), 5):
		x.append(i * j * k * l * t)
	print(max(x))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	if a.count(0) > 0:
		l.append(0)
	b1 = [i for i in a if i > 0]
	b1.sort(reverse=True)
	b = b1[:5]
	c1 = [i for i in a if i < 0]
	c1.sort()
	c = c1[:5]
	for i in range(6):
		if i <= len(b) and 5 - i <= len(c):
			s = 1
			for j in range(i):
				s *= b[j]
			for j in range(5 - i):
				s *= c[j]
			l.append(s)
	if max(l) < 0:
		b1.sort()
		c1.sort(reverse=True)
		b = b1[:5]
		c = c1[:5]
		for i in range(6):
			if i <= len(b) and 5 - i <= len(c):
				s = 1
				for j in range(i):
					s *= b[j]
				for j in range(5 - i):
					s *= c[j]
				l.append(s)
	print(max(l))


def product(a):
	ans = 1
	for i in a:
		ans *= i
	return ans
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a1 = [i for i in a if i < 0]
	a1.sort()
	a2 = [i for i in a if i >= 0]
	a2.sort(reverse=True)
	x1 = len(a1)
	x2 = len(a2)
	if n == 5:
		print(product(a))
	else:
		ans = -float('inf')
		if x2 >= 5:
			p1 = product(a2[:5])
			if p1 > ans:
				ans = p1
		if x2 >= 3 and x1 >= 2:
			l = a2[:3] + a1[:2]
			p2 = product(l)
			if p2 > ans:
				ans = p2
		if x2 >= 1 and x1 >= 4:
			l = a2[:1] + a1[:4]
			p3 = product(l)
			if p3 > ans:
				ans = p3
		if x2 == 0 and x1 >= 5:
			l = a1[x1 - 5:]
			p4 = product(l)
			if p4 > ans:
				ans = p4
		print(ans)


import functools
import operator
t = int(input())

def prod(A):
	return functools.reduce(operator.mul, A, 1)

def func(A):
	return max([prod(A[:i]) * prod(A[len(A) - 5 + i:]) for i in range(6)])
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	ans = func(A)
	print(ans)


n = int(input())
while n:
	x = int(input())
	y = list(map(int, input().split()))
	y.sort()
	f = []
	f.append(y[0] * y[1] * y[2] * y[3] * y[-1])
	f.append(y[0] * y[1] * y[-1] * y[-2] * y[-3])
	f.append(y[-1] * y[-2] * y[-3] * y[-4] * y[-5])
	print(max(f))
	n -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	ne = []
	for i in a:
		if i < 0:
			ne.append(i)
		else:
			p.append(i)
	p.sort(reverse=True)
	ne.sort()
	m = a[0] * a[1] * a[2] * a[3] * a[4]
	for i in range(6):
		s = 1
		if 5 - i > len(p):
			continue
		if i > len(ne):
			break
		for j in range(i):
			if i % 2 == 0:
				s *= ne[j]
			else:
				s *= ne[len(ne) - 1 - j]
		for j in range(5 - i):
			if i % 2 == 0:
				s *= p[j]
			else:
				s *= p[len(p) - 1 - j]
		m = max(m, s)
	print(m)


def max_product(arr):
	s = []
	arr = sorted(arr)
	r = 1
	for i in arr[-1:-6:-1]:
		r *= i
	s.append(r)
	r = 1
	for i in arr[0:2]:
		r *= i
	for i in arr[-1:-4:-1]:
		r *= i
	s.append(r)
	r = 1
	for i in arr[0:4]:
		r *= i
	r *= arr[-1]
	s.append(r)
	result = max(s)
	return result
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	r = max_product(arr)
	print(r)


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	a.sort()
	neg = 0
	for i in a:
		if i < 0:
			neg += 1
	ans = 1
	for i in range(n - 5, n):
		ans *= a[i]
	if neg >= 4:
		ans1 = 1
		for i in range(4):
			ans1 *= a[i]
		ans1 *= a[-1]
		ans = max(ans1, ans)
		ans1 = 1
		for i in range(2):
			ans1 *= a[i]
		ans = max(ans, ans1 * a[-1] * a[-2] * a[-3])
	elif neg >= 2:
		ans1 = 1
		for i in range(2):
			ans1 *= a[i]
		ans = max(ans, ans1 * a[-1] * a[-2] * a[-3])
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	result = float('-inf')
	start = n - 5
	for i in range(6):
		prod = 1
		curr = start
		for j in range(5):
			prod *= arr[curr]
			curr = (curr + 1) % n
		result = max(result, prod)
		start = (start + 1) % n
	print(result)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	value = 0
	if n == 5:
		print(a[0] * a[1] * a[2] * a[3] * a[4])
		continue
	for i in range(n):
		if a[i] > 0:
			value += 1
		else:
			break
	maxneg = -10 ** 20
	maxneg1 = -10 ** 20
	if a[-4] < 0:
		maxneg = a[-1] * a[-2] * a[-3] * a[-4] * a[0]
	if a[-2] < 0:
		maxneg1 = a[-1] * a[-2] * a[0] * a[1] * a[2]
	if value >= 5:
		print(max(a[0] * a[1] * a[2] * a[3] * a[4], maxneg, maxneg1))
	if value == 4:
		print(max(a[0] * a[1] * a[2] * a[-1] * a[-2], maxneg, maxneg1))
	if value == 3:
		print(max(a[0] * a[1] * a[2] * a[-1] * a[-2], maxneg, maxneg1))
	if value == 2:
		print(max(a[0] * a[-4] * a[-3] * a[-1] * a[-2], maxneg))
	if value == 1:
		print(a[0] * a[-4] * a[-3] * a[-1] * a[-2])
	if value == 0:
		print(a[0] * a[1] * a[2] * a[3] * a[4])


t = int(input())
for _ in range(t):
	n = int(input())
	numbers = [int(a) for a in input().split()]
	numbers.sort()
	result = numbers[n - 1]
	i = 0
	j = n - 2
	for _ in range(2):
		d1 = numbers[i] * numbers[i + 1] * result
		d2 = numbers[j] * numbers[j - 1] * result
		if d1 > d2:
			result = d1
			i += 2
		else:
			result = d2
			j -= 2
	print(result)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = array()
	pos = [abs(i) for i in a if i > 0]
	neg = [abs(i) for i in a if i < 0]
	zero = [0 for i in a if i == 0]
	pos.sort(reverse=True)
	neg.sort(reverse=True)
	MAX = -inf
	if len(zero) > 0:
		MAX = 0
	for nc in range(min(6, len(neg) + 1)):
		if len(pos) < 5 - nc:
			continue
		ans = 1
		if nc % 2:
			i = len(neg) - 1
			for __ in range(nc):
				ans *= neg[i]
				i -= 1
			i = len(pos) - 1
			for __ in range(5 - nc):
				ans *= pos[i]
				i -= 1
			MAX = max(MAX, -ans)
		else:
			i = 0
			for __ in range(nc):
				ans *= neg[i]
				i += 1
			i = 0
			for __ in range(5 - nc):
				ans *= pos[i]
				i += 1
			MAX = max(MAX, ans)
	print(MAX)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	neg = []
	pos = []
	for i in a:
		if i < 0:
			neg.append(i)
		else:
			pos.append(i)
	neg.sort(reverse=True)
	pos.sort()
	ans = -10 ** 18
	for i in range(5, 0, -2):
		if len(pos) >= i and len(neg) >= 5 - i:
			curr = 1
			for j in range(-1, -i - 1, -1):
				curr *= pos[j]
			for j in range(-1, -(5 - i) - 1, -1):
				curr *= neg[j]
			ans = max(ans, curr)
		if len(neg) >= i and len(pos) >= 5 - i:
			curr = 1
			for j in range(i):
				curr *= neg[j]
			for j in range(5 - i):
				curr *= pos[j]
			ans = max(ans, curr)
	print(ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	positive = []
	negative = []
	zero = []
	for val in a:
		if val > 0:
			positive.append(val)
		elif val < 0:
			negative.append(val)
		else:
			zero.append(val)
	positive.sort(reverse=True)
	negative.sort()
	ans = -1
	for i in range(0, 5, 2):
		if len(positive) < 5 - i or len(negative) < i:
			continue
		res = 1
		for j in range(i):
			res *= negative[j]
		for j in range(5 - i):
			res *= positive[j]
		ans = max(ans, res)
	if ans != -1:
		print(ans)
	elif zero:
		print(0)
	else:
		positive = positive[::-1]
		negative = negative[::-1]
		ans = -10 ** 30
		for i in range(1, 6, 2):
			if len(positive) < 5 - i or len(negative) < i:
				continue
			res = 1
			for j in range(i):
				res *= negative[j]
			for j in range(5 - i):
				res *= positive[j]
			ans = max(ans, res)
		print(ans)


import sys
input = lambda : sys.stdin.readline().rstrip()

def prod(L):
	s = 1
	for l in L:
		s *= l
	return s
T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) for a in input().split()]
	NE = []
	PO = []
	(po, ne, ze) = (0, 0, 0)
	for a in A:
		if a > 0:
			PO.append(a)
			po += 1
		elif a < 0:
			NE.append(-a)
			ne += 1
		else:
			ze += 1
	PO = sorted(PO)
	NE = sorted(NE)
	ans = -10 ** 100
	if ze:
		ans = max(ans, 0)
	if ne >= 5:
		ans = max(ans, -prod(NE[:5]))
	if po >= 5:
		ans = max(ans, prod(PO[-5:]))
	if po >= 3 and ne >= 2:
		ans = max(ans, prod(PO[-3:]) * prod(NE[-2:]))
	if po >= 1 and ne >= 4:
		ans = max(ans, prod(PO[-1:]) * prod(NE[-4:]))
	if po >= 4 and ne >= 1:
		ans = max(ans, -prod(PO[:4]) * prod(NE[:1]))
	if po >= 2 and ne >= 3:
		ans = max(ans, -prod(PO[:2]) * prod(NE[:3]))
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split() if i != '\n']
	(pos, neg) = ([], [])
	for i in a:
		if i >= 0:
			pos.append(i)
		else:
			neg.append(-i)
	pos.sort(reverse=True)
	neg.sort(reverse=True)
	if n == 5:
		ans = 1
		for i in range(5):
			ans = ans * a[i]
		print(ans)
	elif len(pos) == 0:
		ans = 1
		neg.sort()
		for i in range(5):
			ans = ans * neg[i]
		print(-ans)
	elif len(neg) == 0:
		ans = 1
		for i in range(5):
			ans = ans * pos[i]
		print(ans)
	else:
		ans = []
		if len(neg) >= 2 and len(pos) >= 3:
			ans.append(neg[0] * neg[1] * pos[0] * pos[1] * pos[2])
		if len(neg) >= 4 and len(pos) >= 1:
			ans.append(neg[0] * neg[1] * neg[2] * neg[3] * pos[0])
		if len(pos) >= 5:
			ans.append(pos[0] * pos[1] * pos[2] * pos[3] * pos[4])
		print(max(ans))