#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, p, aux;
  bool b = true;
  cin >> n;
  vector<long long> v;
  for (i = 0; i < n; i++) {
    cin >> aux;
    v.push_back(aux);
  }
  p = 0;
  for (i = 1; i < n; i++) {
    if (v[i] > v[i - 1] && p != 0) b = false;
    if (v[i] == v[i - 1] && p == 0) p = 1;
    if (v[i] == v[i - 1] && p != 1) b = false;
    if (v[i] < v[i - 1] && (p == 1 || p == 0)) p = 2;
    if (v[i] < v[i - 1] && p != 2) b = false;
  }
  if (b)
    cout << "YES\n";
  else
    cout << "NO\n";
}
