#include <bits/stdc++.h>
using namespace std;
int v[200009];
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  int n, p;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
    if (v[i] == n) p = i;
  }
  for (int i = p - 1; i > 0; --i)
    if (v[i] > v[i + 1]) return cout << "NO", 0;
  for (int i = p + 1; i <= n; ++i)
    if (v[i] > v[i - 1]) return cout << "NO", 0;
  cout << "YES\n";
  return 0;
}
