#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[10007];
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int i = 1;
  while (i + 1 <= n && a[i + 1] > a[i]) i++;
  while (i + 1 <= n && a[i + 1] == a[i]) i++;
  while (i + 1 <= n && a[i + 1] < a[i]) i++;
  puts(i == n ? "YES" : "NO");
  return 0;
}
