#include <bits/stdc++.h>
using namespace std;
const long long base = 1e9 + 7;
const double pi = 3.1415926535897932;
const long long oo = 9223372036854775807;
const long inf = 2147483647;
const bool Eureka = 1;
int a[300005];
int i, j, t, n;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = (1); i <= (n); ++i) {
    cin >> a[i];
    if (a[i] == n) t = i;
  }
  i = t - 1;
  j = t + 1;
  t = a[t];
  a[0] = -inf;
  a[n + 1] = -inf;
  do {
    if (a[i] < a[j] && abs(a[j] - t) == 1) {
      j++;
      t = a[j - 1];
    } else if (a[i] > a[j] && abs(a[i] - t) == 1) {
      i--;
      t = a[i + 1];
    } else
      break;
  } while (true);
  if (i < 1 && j > n)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
