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