#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    vec.push_back(val);
  }
  int lar_ind = 0, lar_num = 0;
  for (int i = 0; i < vec.size(); i++) {
    if (vec[i] > lar_num) {
      lar_num = vec[i];
      lar_ind = i;
    }
  }
  bool left = true, right = true;
  for (int i = 0; i < lar_ind; i++) {
    if (vec[i + 1] < vec[i]) {
      left = false;
      break;
    }
  }
  for (int i = lar_ind; i < vec.size() - 1; i++) {
    if (vec[i + 1] > vec[i]) {
      right = false;
      break;
    }
  }
  if (right && left)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
