#include<cstdio>
int n,a[];
int main(){
scanf("%d",&n);
for(int i=;i<=n;++i)scanf("%d",a+i);
int L=,R=n;
while(L<n&&a[L]<a[L+])++L;
while(R>&&a[R]<a[R-])--R;
for(int i=L+;i<=R;++i)if(a[L]!=a[i])return puts("NO"),;
return puts("YES"),;
}
#include <iostream>
using namespace std;
int N;
int V[];
int main()
{
cin>>N;
for(int i=;i<=N;i++)cin>>V[i];
int i=;
while(i<N&&V[i]<V[i+])i++;
while(i<N&&V[i]==V[i+])i++;
while(i<N&&V[i]>V[i+])i++;
if(i<N)cout<<"NO";
else cout<<"YES";
return ;
}
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int a[];
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)scanf("%d",a+i);
int i=;
while(i+<=n && a[i+]>a[i])i++;
while(i+<=n && a[i+]==a[i])i++;
while(i+<=n && a[i+]<a[i])i++;
if(i<n)printf("NO");else printf("YES");
return ;
}
#include<bits/stdc++.h>
using namespace std; int main()
{
int n;
cin>>n;
int arr[n];
for(int i=;i<n;i++)
cin>>arr[i];
int i=;
while(arr[i+]>arr[i] && i+<n)
i++;
while(arr[i]==arr[i+] && i+<n)
i++;
while(arr[i]>arr[i+] && i+<n)
i++;
if(i==n-)
cout<<"YES";
else cout<<"NO"; }
#include <bits/stdc++.h> using namespace std; int a[];
int n;
void sol(string s) {
cout << s;
exit();
}
int main() {
#ifndef ONLINE_JUDGE
freopen("CF.in", "r", stdin);
#endif
cin >> n;
for (int i = ; i <= n; ++i)cin >> a[i];
int i=;
while(i+<=n&&a[i]<a[i+])++i;
while(i+<=n&&a[i]==a[i+])++i;
while(i+<=n)
{
if(a[i]<=a[i+])sol("NO");
++i;
}sol("YES");
}