#include <bits/stdc++.h>
using namespace std;
int main() {
  int l;
  cin >> l;
  int* x = new int[l];
  for (int i = 0; i < l; i++) {
    cin >> x[i];
  }
  if (l == 1) {
    cout << "YES" << endl;
    return 0;
  }
  int state = 0;
  int prev = x[0];
  for (int i = 1; i < l; i++) {
    int cur = x[i];
    switch (state) {
      case 0:
        if (cur == prev) {
          state = 1;
        } else if (cur < prev) {
          state = 2;
        }
        break;
      case 1:
        if (cur > prev) {
          cout << "NO" << endl;
          return 0;
        } else if (cur < prev) {
          state = 2;
        }
        break;
      case 2:
        if (cur > prev || cur == prev) {
          cout << "NO" << endl;
          return 0;
        }
        break;
    }
    prev = cur;
  }
  cout << "YES" << endl;
  return 0;
}
