#include <bits/stdc++.h>
using namespace std;
long long modularExponentiation(long long x, long long n,
                                long long M = 1000000007) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return modularExponentiation((x * x) % M, n / 2, M);
  else
    return (x * modularExponentiation((x * x) % M, (n - 1) / 2, M)) % M;
}
long long abs(long long a, long long b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}
void solve();
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
void solve() {
  long long n;
  cin >> n;
  long long a[n], m = 0, j;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > m) {
      m = a[i];
      j = i;
    }
  }
  long long i = j;
  while (i > 0) {
    if (a[i] <= a[i - 1]) break;
    i--;
  }
  if (i) {
    cout << "NO"
         << "\n";
    return;
  }
  i = j;
  while (i < n - 1) {
    if (a[i] <= a[i + 1]) break;
    i++;
  }
  if (i != n - 1) {
    cout << "NO"
         << "\n";
    return;
  }
  cout << "YES"
       << "\n";
}
