#include <bits/stdc++.h>
using namespace std;
int n;
int a[110];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  bool ok = true;
  int lo = 0;
  while (lo < n - 1 && a[lo] < a[lo + 1]) lo++;
  while (lo < n - 1 && a[lo] == a[lo + 1]) lo++;
  while (lo < n - 1 && a[lo] > a[lo + 1]) lo++;
  if (lo == n - 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
