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