#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef std::pair<int,int> sp;
bool spc(sp one,sp two)
{
return one.first*one.second<two.first*two.second;
}
void check(int &lhs,int &rhs,int cur,int a1,int min)
{
sp tmp1=sp(lhs,rhs);
sp tmp2=sp(lhs,cur);
sp tmp3=sp(a1,cur);
sp tmp4=sp(min,cur);
std::vector<sp> res;
res.push_back(tmp1);res.push_back(tmp2);res.push_back(tmp3);
res.push_back(tmp4);
std::sort(res.begin(),res.end(),spc);
lhs=res[0].first;rhs=res[0].second;
}
int main()
{
int lhs=1000,rhs=1000,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,m=0,cur=0;
int N;
cin>>N;
int i=0;
for(i;i<6;i++)
{
a1=a2;
a2=a3;
a3=a4;
a4=a5;
a5=a6;
cin>>cur;
a6=cur;
}
m=a1;
for(i;i<N;i++)
{
cin>>cur;
check(lhs,rhs,cur,a1,m);
m=std::min(m,a1);
a1=a2;
a2=a3;
a3=a4;
a4=a5;
a5=a6;
a6=cur;
}
cout<<endl<<endl;
cout<<lhs*rhs;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIHN0ZDo6cGFpcjxpbnQsaW50PiBzcDsKYm9vbCBzcGMoc3Agb25lLHNwIHR3bykKewoJcmV0dXJuIG9uZS5maXJzdCpvbmUuc2Vjb25kPHR3by5maXJzdCp0d28uc2Vjb25kOwp9CnZvaWQgY2hlY2soaW50ICZsaHMsaW50ICZyaHMsaW50IGN1cixpbnQgYTEsaW50IG1pbikKewoJc3AgdG1wMT1zcChsaHMscmhzKTsKCXNwIHRtcDI9c3AobGhzLGN1cik7CglzcCB0bXAzPXNwKGExLGN1cik7CglzcCB0bXA0PXNwKG1pbixjdXIpOwoJc3RkOjp2ZWN0b3I8c3A+IHJlczsKCXJlcy5wdXNoX2JhY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