#include <bits/stdc++.h>
using namespace std;
int arr[10000], cnt[100000];
int main() {
  int n, i, j, k, l;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> arr[i];
  int flag = 0;
  for (i = 1; i <= n; i++) {
    cnt[i] = arr[i] - arr[i - 1];
  }
  for (i = 2; i <= n; i++) {
    if (flag == 0) {
      if (cnt[i] > 0) {
        flag = 1;
      }
      if (cnt[i] == 0) {
        flag = 2;
      }
      if (cnt[i] < 0) {
        flag = 3;
      }
    } else if (flag == 1) {
      if (cnt[i] > 0) {
        flag = 1;
      }
      if (cnt[i] == 0) {
        flag = 2;
      }
      if (cnt[i] < 0) {
        flag = 3;
      }
    } else if (flag == 2) {
      if (cnt[i] > 0) {
        cout << "NO" << endl;
        return 0;
      }
      if (cnt[i] == 0) {
        flag = 2;
      }
      if (cnt[i] < 0) {
        flag = 3;
      }
    } else if (flag == 3) {
      if (cnt[i] > 0) {
        cout << "NO" << endl;
        return 0;
      }
      if (cnt[i] == 0) {
        cout << "NO" << endl;
        return 0;
      }
      if (cnt[i] < 0) {
        flag = 3;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
