#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n;
int a[N];
int dio[N];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    if (a[i] > a[i - 1]) dio[i] = 1;
    if (a[i] == a[i - 1]) dio[i] = 2;
    if (a[i] < a[i - 1]) dio[i] = 3;
  }
  bool jel = true;
  int pred = -1;
  for (int i = 1; i < n; i++) {
    if (dio[i] < pred) jel = false;
    pred = dio[i];
  }
  if (jel)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
