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