#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long i, j;
long long temp;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long a[n + 2];
  for (i = 1; i < n + 1; i++) cin >> a[i];
  a[0] = a[n + 1] = -1;
  long long l = 0, m = 1, r = 2;
  long long ma = a[1];
  for (i = 1; i < n + 1; i++) {
    if (a[i] > ma) {
      ma = a[i];
      m = i;
      l = i - 1;
      r = i + 1;
    }
  }
  long long cnt = 0;
  while (1) {
    if (cnt == n - 1) break;
    if (l != 0 && a[l] == a[m] - 1) {
      m = l;
      l--;
      cnt++;
    } else if (r != n + 1 && a[r] == a[m] - 1) {
      m = r;
      r++;
      cnt++;
    } else {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
