#include<bits/stdc++.h>
using namespace std;
int arr[100005];
int lsl[100005];
int lgr[100005];
stack<int> s;
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&arr[i]);
int largest=-1;
for(int i=n-1;i>=0;i--)
{
if((largest==-1)||(largest!=-1&&arr[i]<arr[largest]))
lgr[i]=largest;
else
lgr[i]=-1;
if((largest==-1)||(largest!=-1&&arr[i]>arr[largest]))
largest=i;
}
for(int i=0;i<n;i++)
{
if(lgr[i]==-1)
{
lsl[i]=-1;
continue;
}
int max=-1;
while(!s.empty()&&arr[s.top()]<arr[i])
max=s.top(),s.pop();
lsl[i]=max;
s.push(i);
}
int ma=-1;
int maxi=-1,maxj=-1,maxk=-1;
for(int i=1;i<n-1;i++)
{
if(lsl[i]!=-1&&lgr[i]!=-1)
{
if(ma<arr[lsl[i]]*arr[i]*arr[lgr[i]])
{
maxi=lsl[i];
maxj=i;
maxk=lgr[i];
ma=arr[lsl[i]]*arr[i]*arr[lgr[i]];
}
}
}
if(ma!=-1)
printf("The numbers are %d %d %d with product value %d\n",arr[maxi],arr[maxj],arr[maxk],ma);
else
printf("No such sequence exist\n");
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGFyclsxMDAwMDVdOwppbnQgbHNsWzEwMDAwNV07CmludCBsZ3JbMTAwMDA1XTsKc3RhY2s8aW50PiBzOwppbnQgbWFpbigpCnsKCWludCBuOwoJc2NhbmYoIiVkIiwmbik7Cglmb3IoaW50IGk9MDtpPG47aSsrKQoJCXNjYW5mKCIlZCIsJmFycltpXSk7CglpbnQgbGFyZ2VzdD0tMTsKCWZvcihpbnQgaT1uLTE7aT49MDtpLS0pCgl7CgkJaWYoKGxhcmdlc3Q9PS0xKXx8KGxhcmdlc3QhPS0xJiZhcnJbaV08YXJyW2xhcmdlc3RdKSkKCQkJbGdyW2ldPWxhcmdlc3Q7CgkJZWxzZQoJCQlsZ3Jba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