#include<string>
#include <iostream>
using namespace std;
int main() {
int a[100000],t,n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
bool flag = false;
for (int i = 1; i < n; i++) {
if (a[i] < a[i - 1])
{
cout << "NO";
flag = true;
break;
}
}
if(flag==false)
cout << "YES";
}