#include <bits/stdc++.h>
int main(int argc, char* argv[]) {
  int n;
  std::cin >> n;
  if (n == 1) {
    std::cout << "YES" << std::endl;
    return 0;
  }
  int curr_block = 1;
  int a_prev, a;
  std::cin >> a_prev;
  for (int i = 1; i < n; ++i) {
    std::cin >> a;
    if (curr_block == 1) {
      if (a_prev < a) {
        a_prev = a;
      } else if (a_prev == a) {
        a_prev = a;
        curr_block = 2;
      } else {
        a_prev = a;
        curr_block = 3;
      }
    } else if (curr_block == 2) {
      if (a_prev < a) {
        std::cout << "NO" << std::endl;
        return 0;
      } else if (a_prev == a) {
        a_prev = a;
      } else {
        a_prev = a;
        curr_block = 3;
      }
    } else {
      if (a_prev < a) {
        std::cout << "NO" << std::endl;
        return 0;
      } else if (a_prev == a) {
        std::cout << "NO" << std::endl;
        return 0;
      } else {
        a_prev = a;
      }
    }
  }
  std::cout << "YES" << std::endl;
  return 0;
}
