#include <iostream>
using namespace std;
const int N = 1e5 + 5;
int main() {
int a[N], num;
scanf("%d", &num);
for (int i = 0; i < num; i++) {
cin >> a[i];
}
for (int i = 0; i < num-1; i++) {
if (a[i] > a[i+1]) {
printf("NO");
return 0;
}
}
printf("YES");
return 0;
}