#include <bits/stdc++.h>
using namespace std;
int a[110];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 1 || n == 2) {
    cout << "YES";
    return 0;
  }
  int f = 1;
  while (f < n && a[f] > a[f - 1]) f++;
  int b = n - 2;
  while (b >= 0 && a[b] > a[b + 1]) b--;
  f--;
  b++;
  int val = a[f];
  for (int j = f; j <= b; j++) {
    if (a[j] != val) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
