#include <bits/stdc++.h>
namespace {
using number_t = long long;
enum state_t { increasing, equale, decreasing };
}  // namespace
int main() {
  int N;
  std::cin >> N;
  std::vector<int> arr(N);
  for (auto& el : arr) {
    std::cin >> el;
  }
  state_t state = state_t::increasing;
  for (size_t i = 0; i < arr.size() - 1; ++i) {
    switch (state) {
      case state_t::increasing:
        if (arr[i] == arr[i + 1]) {
          state = state_t::equale;
        }
        if (arr[i] > arr[i + 1]) {
          state = state_t::decreasing;
        }
        break;
      case state_t::equale:
        if (arr[i] > arr[i + 1]) {
          state = state_t::decreasing;
        }
        if (arr[i] < arr[i + 1]) {
          std::cout << "NO" << std::endl;
          return 0;
        }
        break;
      case state_t::decreasing:
        if (arr[i] <= arr[i + 1]) {
          std::cout << "NO" << std::endl;
          return 0;
        }
        break;
    };
  }
  std::cout << "YES" << std::endl;
  return 0;
}
