#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, ind;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == n) ind = i;
  }
  bool f = true;
  for (long long i = ind + 1; i < n - 1; i++) {
    if (a[i] < a[i + 1]) f = false;
  }
  for (long long i = ind - 1; i > 0; i--) {
    if (a[i] < a[i - 1]) f = false;
  }
  if (f)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
