#include <bits/stdc++.h>
using namespace std;
int v[105];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
  int aa = 2;
  while (v[aa] > v[aa - 1]) aa++;
  while (v[aa] == v[aa - 1]) aa++;
  while (v[aa] < v[aa - 1]) aa++;
  if (aa > n)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
