#include <bits/stdc++.h>
int main(void) {
  int n;
  scanf("%d", &n);
  int A[n];
  int i;
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
  if (n == 1) {
    printf("YES");
    return 0;
  }
  int mode;
  int s1 = 0, s2 = 0;
  if (A[1] > A[0])
    mode = 1;
  else if (A[1] < A[0])
    mode = -1;
  else
    mode = 0;
  for (i = 1; i < n - 1; i++) {
    if (A[i + 1] > A[i]) {
      if ((mode == -1) || (mode == 0)) {
        printf("NO");
        return 0;
      }
    }
    if (A[i + 1] == A[i]) {
      if (mode == -1) {
        printf("NO");
        return 0;
      } else {
        mode = 0;
      }
    }
    if (A[i + 1] < A[i]) {
      mode = -1;
    }
  }
  printf("YES");
  return 0;
}
