#include <bits/stdc++.h>
using namespace std;
int a;
int n;
int main() {
  cin >> n;
  int s = 0;
  int l = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (l == 0) {
      if (a > s) {
        s = a;
      } else if (a == s) {
        l = 1;
        s = a;
      } else {
        l = 2;
        s = a;
      }
    } else if (l == 1) {
      if (a > s) {
        cout << "NO";
        return 0;
      } else if (a < s) {
        l = 2;
        s = a;
      }
    } else {
      if (a >= s) {
        cout << "NO";
        return 0;
      }
    }
    s = a;
  }
  cout << "YES";
}
