My solution to this problem-
#include
using namespace std;
int main() {
int n,num;
cin>>n>>num;
int temp=num;
int j=0,k=0;
for(int i=2;i<=n;i++)
{
cin>>num;
if(temp>num and i==j+2)
j++;
else if( temp<num and i==j+k+2)
k++;
else if(temp==num and i==j+2)
k++;
}
if(j+k==n-1)
cout<<"true"<<endl;
else
cout<<"false"<<endl;
return 0;
}