#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x[100] = {0}, pos1, pos2;
  bool f1 = false, f2 = true;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  x[n + 1] = 0;
  for (int i = 0; i <= n; i++) {
    if (x[i] < x[i + 1]) continue;
    f1 = true;
    pos1 = i;
    break;
  }
  for (int i = pos1; i <= n; i++) {
    if (x[i] == x[i + 1]) continue;
    pos2 = i;
    break;
  }
  for (int i = pos2; i <= n; i++) {
    if (x[i] > x[i + 1]) continue;
    f2 = false;
    break;
  }
  if (!f2)
    printf("NO\n");
  else if (f1 && f2)
    printf("YES\n");
  return 0;
}
