#include <bits/stdc++.h>
using namespace std;
int n;
const int MAXN = 105;
int uni[MAXN];
bool inc = false, cons = false, decr = false;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> uni[i];
  for (int i = 1; i < n; i++) {
    if (uni[i] - uni[i - 1] > 0) {
      if (cons || decr) {
        cout << "NO\n";
        return 0;
      } else
        inc = true;
    } else if (uni[i] - uni[i - 1] == 0) {
      if (decr) {
        cout << "NO\n";
        return 0;
      } else
        cons = true;
    } else
      decr = true;
  }
  cout << "YES\n";
  return 0;
}
