#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int last = -1, flag = 0, c = 0;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    if (y > last) {
      if (flag == 1 || flag == 2) c = 1;
    } else if (y == last) {
      if (flag == 0)
        flag = 1;
      else if (flag == 2)
        c = 1;
    } else {
      flag = 2;
    }
    last = y;
  }
  if (c == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
