#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int tab[n];
  if (n == 1 or n == 2) {
    cout << "YES";
    return 0;
  }
  for (int i = 0; i < n; i++) cin >> tab[i];
  bool ans = true;
  int mode = 0;
  for (int i = 1; i < n; i++) {
    if (mode == 0 and tab[i - 1] < tab[i]) continue;
    if (mode == 0 and tab[i - 1] == tab[i]) {
      mode = 1;
      continue;
    }
    if (mode == 0 and tab[i - 1] > tab[i]) {
      mode = 2;
      continue;
    }
    if (mode == 1 and tab[i - 1] == tab[i]) continue;
    if (mode == 1 and tab[i - 1] < tab[i]) {
      cout << "NO";
      return 0;
    }
    if (mode == 1 and tab[i - 1] > tab[i]) {
      mode = 2;
      continue;
    }
    if (mode == 2 and tab[i - 1] > tab[i]) continue;
    cout << "NO";
    return 0;
  }
  cout << "YES";
  return 0;
}
