#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, num;
  scanf("%d", &n);
  int f = 0;
  int pre = 0;
  bool ans = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &num);
    if ((f == 1 && num > pre) || (f == 2 && num >= pre)) ans = 0;
    if (num == pre) f = 1;
    if (num < pre) f = 2;
    pre = num;
  }
  if (ans)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
