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