#include <bits/stdc++.h>
long long n, i, x, a[200005];
inline void read(long long &x) {
  short negative = 1;
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') negative = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  x *= negative;
}
signed main(void) {
  read(n);
  for (i = 1; i <= n; i++) read(a[i]);
  for (i = 1; i <= n; i++)
    if (a[i] > a[i + 1]) break;
  if (i == n) return putchar('Y'), putchar('E'), putchar('S'), 0;
  for (; i < n; i++)
    if (a[i] < a[i + 1]) return putchar('N'), putchar('O'), 0;
  putchar('Y'), putchar('E'), putchar('S');
  return 0;
}
