#include <stdio.h>
int main(void) {
int N, i = 0;
scanf("%d", &N);
int A[N];
for (int x = 0; x < N; x++) {
scanf("%d", &A[x]);
}
while (i + 1 < N && A[i] < A[i+1]) {
i++;
}
while (i + 1 < N && A[i] > A[i+1]) {
i++;
}
if(i == N - 1) {
printf("YES");
} else {
printf("NO");
}
}