#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, i, j, A[200005], s = 1;
  cin >> n;
  for (long long(i) = 0; (i) < (n); (i) = (i + 1)) {
    cin >> A[i];
    if (A[i] == n) {
      k = i;
    }
  }
  for (j = k; j < n - 1; j++) {
    if (A[j] < A[j + 1]) {
      s = 0;
      break;
    }
  }
  if (s != 0) {
    for (j = k; j > 0; j--) {
      if (A[j] < A[j - 1]) {
        s = 0;
        break;
      }
    }
    s == 0 ? cout << "NO" : cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
