#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
string solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long i = 0;
  while (i < n - 1 && a[i + 1] > a[i]) {
    i++;
  }
  for (long long j = i; j < n - 1; j++) {
    if (a[j + 1] > a[j]) {
      return "NO";
    }
  }
  return "YES";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << solve();
  return 0;
}
