#include <bits/stdc++.h>
using namespace std;
const long long maxn=1e7+10;
long long a[maxn],i,n,ln;
int main()
{
freopen("capso.inp","r",stdin);
freopen("capso.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
sort(a+1,a+n+1);
ln=a[1]*a[2]*a[3];
for (i=2; i<=n-1; i++)
ln=max(ln,a[i-1]*a[i]*a[i+1]);
cout<<ln;
return 0;
}