#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, a[200005], pos, l, r, val;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == n) pos = i;
  }
  l = pos - 1;
  r = pos + 1;
  val = n - 1;
  while (val >= 1) {
    if (a[l] == val) {
      l--;
      val--;
    } else if (a[r] == val) {
      r++;
      val--;
    } else
      break;
  }
  if (val >= 1) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
  }
  return 0;
}
