#include <bits/stdc++.h>
int n, a[200005];
bool check1(int x) {
  for (int i = x + 1; i <= n; i++)
    if (a[i] >= a[i - 1]) return 0;
  return 1;
}
bool check2(int x) {
  for (int i = x + 1; i <= n; i++)
    if (a[i] <= a[i - 1]) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (check1(1) || check2(1)) {
    printf("YES");
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    if (a[i] <= a[i - 1]) {
      if (check1(i))
        printf("YES");
      else
        printf("NO");
      return 0;
    }
  }
  return 0;
}
