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