#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
long long n;
cin>>n;
long long arr[n];
for(long long i=0;i<n;i++){
cin>>arr[i];
}
for(long long i=0;i<n - 1;i++){
if(arr[i] > arr[i+1]){
cout<<"NO"<<endl;
return 0;
}
}
cout<<"YES"<<endl;
return 0;
}