#include <iostream>
#include <string.h>
#include<vector>
#include<queue>
#include<stack>
#include<array>
using namespace std;
int sum1(int a) {
int l = 0;
while (a != 0) {
l = l + a % 10;
a = a / 10;
if (l >= 10)
l = l / 10;
}
return l;
}
string get() {
int n;
long long int*h=new long long int[100005];
cin >> n;
int t;
for (int i = 0;i < n;i++)
{
cin >> h[i];
}
for (int i = n - 1;i > 0;i--) {
if (h[i] < h[i - 1])
return "NO";
}
return "YES";
}
int main() {
cout<<get();
return 0;
}