#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
vector<int> v;
int main() {
  ios_base::sync_with_stdio(0);
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, x;
  bool tt = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    v.push_back(x);
  }
  for (int i = 1; i < n; ++i) {
    if (v[i] <= v[i - 1])
      tt = true;
    else if (tt && v[i] > v[i - 1])
      return cout << "NO\n", 0;
  }
  reverse(v.begin(), v.end());
  tt = 0;
  for (int i = 1; i < n; ++i) {
    if (v[i] <= v[i - 1])
      tt = true;
    else if (tt && v[i] > v[i - 1])
      return cout << "NO\n", 0;
  }
  cout << "YES\n";
  return 0;
}
