#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
int a[maxn];
void solve() {
  int n, p, m, k, z, y, x;
  scanf("%d", &n);
  x = INT_MIN;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > x) {
      x = a[i];
      y = i;
    }
  }
  z = y;
  while (y > 0) {
    if (a[y] == x)
      y--;
    else
      break;
  }
  while (z <= n) {
    if (a[z] == x)
      z++;
    else
      break;
  }
  x = 0;
  for (int i = 2; i <= y; i++) {
    if (a[i] <= a[i - 1]) {
      x = 1;
      break;
    }
  }
  if (x) {
    puts("NO");
    return;
  }
  x = 0;
  for (int i = z; i <= n; i++) {
    if (a[i] <= a[i + 1]) {
      x = 1;
      break;
    }
  }
  if (x) {
    puts("NO");
    return;
  }
  puts("YES");
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
