#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100;
int data[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &data[i]);
  int l = 1, r = n;
  while (l < n && data[l] < data[l + 1]) l++;
  while (r > 1 && data[r] < data[r - 1]) r--;
  int flag = 1;
  if (l > r) flag = 0;
  for (int i = l; i < r; ++i) {
    if (data[i] != data[i + 1]) flag = 0;
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
