#include <iostream>
using namespace std;
int main() {
int N, person, before = 0;
cin >> N;
if (N == 1) {
cout << "YES";
return 0;
}
while (N--) {
cin >> person;
if (before > person) {
cout << "NO";
return 0;
}
before = person;
}
cout << "YES";
}