#include <bits/stdc++.h>
#pragma comment(linker, "/stack:640000000")
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    int arr[200];
    arr[0] = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
    int i = 0, j = 1;
    while (j <= n && arr[j] > arr[i]) {
      j++;
      i++;
    }
    while (j <= n && arr[j] == arr[i]) {
      j++;
      i++;
    }
    while (j <= n && arr[j] < arr[i]) {
      j++;
      i++;
    }
    if (n == 1 || j == n + 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
