#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int
using namespace std;
int main() {
ll n, height;
vector<int> v;
cin >> n;
while (n--) {
cin >> height;
v.push_back(height);
}
if (is_sorted(v.begin(), v.end()))
cout << "YES" << endl;
else
cout << "NO" << endl;
}