#include <bits/stdc++.h>
using namespace std;
int n;
int a[200001];
int idx = 1;
template <typename T>
inline T read() {
  T x = 0;
  T multiplier = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') {
      multiplier = -1;
    }
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch & 15);
    ch = getchar();
  }
  return x * multiplier;
}
int main() {
  n = read<int>();
  for (int i = 1; i <= n; i++) {
    a[i] = read<int>();
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] > a[idx]) {
      idx = i;
    }
  }
  for (int i = 1; i < idx; i++) {
    if (a[i] > a[i + 1]) {
      puts("NO");
      exit(0);
    }
  }
  for (int i = idx + 1; i <= n; i++) {
    if (a[i - 1] < a[i]) {
      puts("NO");
      exit(0);
    }
  }
  puts("YES");
  return 0;
}
