#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 5;
int ar[maxn];
int main() {
  int n;
  while (cin >> n) {
    memset(ar, 0, sizeof(ar));
    for (int i = 0; i < n; i++) cin >> ar[i];
    if (1 == n) {
      cout << "YES" << endl;
      continue;
    }
    int flag = 0;
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (flag == 0 && ar[j] < ar[j + 1]) {
        cnt++;
      }
      if ((flag == 0 || flag == 1) && ar[j] == ar[j + 1]) {
        flag = 1;
        cnt++;
      }
      if (ar[j] > ar[j + 1]) {
        flag = 2;
        cnt++;
      }
    }
    if (cnt == n)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
