#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, mx = -1, pos_mx = -1;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    if (v[i] > mx) {
      mx = v[i];
      pos_mx = i;
    }
  }
  int tf = 1;
  for (int i = 0; i < pos_mx; ++i) {
    if (v[i] >= v[i + 1]) tf = 0;
  }
  for (int i = pos_mx + 1; i < n - 1; ++i) {
    if (v[i] <= v[i + 1]) tf = 0;
  }
  cout << ((tf == 0) ? "NO" : "YES");
}
