#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
int n;
int a[MAX];
inline int read();
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  int pos;
  for (int i = 1; i <= n; ++i)
    if (a[i] == n) {
      pos = i;
      break;
    }
  for (int i = pos - 1; i >= 1; --i) {
    if (a[i] > a[i + 1]) {
      printf("NO\n");
      return 0;
    }
  }
  for (int i = pos + 1; i <= n; ++i) {
    if (a[i] > a[i - 1]) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}
inline int read() {
  char tmp = getchar();
  int sum = 0;
  bool flag = false;
  while (tmp < '0' || tmp > '9') {
    if (tmp == '-') flag = true;
    tmp = getchar();
  }
  while (tmp >= '0' && tmp <= '9') {
    sum = (sum << 1) + (sum << 3) + tmp - '0';
    tmp = getchar();
  }
  return flag ? -sum : sum;
}
