#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int i = 1;
  while (i < n) {
    if (a[i] > a[i - 1])
      i++;
    else
      break;
  }
  if (n == 1) {
    cout << "YES";
    return 0;
  }
  while (i < n) {
    if (a[i] == a[i - 1])
      i++;
    else
      break;
  }
  while (i < n) {
    if (a[i] < a[i - 1])
      i++;
    else
      break;
  }
  if (i == n)
    cout << "YES";
  else
    cout << "NO";
}
