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