#include <iostream>
using namespace std;
//G ANTON CANT SEE
int main() {
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
//cout<<a[i]<<" ";
}
for(int i=0;i<n-1;i++){
// cout<<a[i]<<" ";
if(a[i]>a[i+1]) {
cout<<"NO"<<endl;
return 0;
}
}
cout<<"YES"<<endl;
return 0;
}