#include <bits/stdc++.h>
using namespace std;
void doit() {
  long long n, i, x, in, me = 0;
  bool ok = 0;
  cin >> n;
  vector<long long> v(n);
  for (i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] > me) {
      in = i;
      me = v[i];
    }
  }
  for (i = in - 1; i >= 0; i--) {
    if (v[i] > v[i + 1]) {
      cout << "NO"
           << "\n";
      return;
    }
  }
  for (i = in + 1; i < n; i++) {
    if (v[i] > v[i - 1]) {
      cout << "NO"
           << "\n";
      return;
    }
  }
  cout << "YES"
       << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    doit();
  }
}
