#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 2e5 + 5;
int n, a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int idx = -1;
  for (int i = 1; i <= n; i++)
    if (a[i] == n) idx = i;
  bool f = true;
  for (int i = 1; i < idx; i++) {
    if (a[i] > a[i + 1]) f = false;
  }
  for (int i = idx; i < n; i++) {
    if (a[i] < a[i + 1]) f = false;
  }
  cout << (f ? "YES" : "NO") << "\n";
  return 0;
}
