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