#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
int a[200000];
while(scanf("%d",&n) != EOF && n){
for(int i = 0;i < n;i++){
scanf("%d",&a[i]);
}
int flag = 1,i;
for(i = 0;i <= n-3;i++){
if(a[i] == a[i+1]){
flag = 0;
break;
}
if(a[i] > a[i+1] && a[i+2] > a[i+1]){
flag = 0;
break;
}
}
if(a[i] == a[i+1]){
flag = 0;
}
if(flag){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
}
1.出现"凹谷"就不行,例如 9 3 4 ,3就是凹谷;
2相邻两个之间相同就不行,例如 9 4 4 ,第二个4套不上去;