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