-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeForces-1406B.cpp
78 lines (63 loc) · 2.31 KB
/
CodeForces-1406B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// Created by abdob on 10/29/2022.
//
#include<bits/stdc++.h>
#include<stdio.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define ll long long
#define scl(n) scanf("%lld",&n)
#define scll(n, m) scanf("%lld%lld",&n, &m)
#define scc(c) scanf("%c",&c)
#define fr(i,n) for (ll i=0;i<n;i++)
#define fr1(i,n) for(ll i=1;i<=n;i++)
#define pfl(x) printf("%lld\n",x)
#define pb push_back
#define debug cout<<"I am here"<<endl;
#define pno cout<<"NO"<<endl
#define pys cout<<"YES"<<endl
#define tcas(i,t) for(ll i=1;i<=t;i++)
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(),(x).rend()
#define pr pair<ll, ll>
#define ff first
#define ss second
#define pn printf("\n")
#define l(s) s.size()
#define asort(a) sort(a,a+n)
#define dsort(a) sort(a,a+n,greater<int>())
#define uniquee(x) x.erase(unique(x.begin(), x.end()),x.end())
#define el cout<<endl
#define md 1000000007
#define inf 1e18
#define ps cout<<" ";
#define Pai acos(-1.0)
#define mem(a,i) memset(a, i, sizeof(a))
#define pcas(i) cout<<"Case "<<i<<": "<<endl;
#define seg_tree(n) ll left=n*2,right=l+1,mid=(l+r)/2
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define N 200005
int main()
{
ll t;
cin>>t;
tcas(cs, t)
{
ll m,n,b,c,d,i,j,k,x,y,z,l,r, p, q;
string s,s1, s2, s3, s4;
ll cnt=0,cn=0,ans=-inf,sum=0 , neg=0 , pos=0;
cin>>n;
ll a[n];
fr(i,n) cin>>a[i];
asort(a);
ans=max(ans , a[n-5]*a[n-4]*a[n-3]*a[n-2]*a[n-1] );
ans=max(ans , a[0]*a[n-4]*a[n-3]*a[n-2]*a[n-1] );
ans=max(ans , a[0]*a[1]*a[n-3]*a[n-2]*a[n-1] );
ans=max(ans , a[0]*a[1]*a[2]*a[n-2]*a[n-1] );
ans=max(ans , a[0]*a[1]*a[2]*a[3]*a[n-1] );
ans=max(ans , a[0]*a[1]*a[2]*a[3]*a[4] );
cout<<ans;pn;
}
return 0;
}