#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int INF64 = mod * mod + 1;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  long long int maxpos;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == n) maxpos = i;
  }
  bool ans = true;
  for (long long int j = maxpos - 1; j >= 0; j--) {
    if (a[j] > a[j + 1]) {
      ans = false;
      break;
    }
  }
  for (long long int j = maxpos + 1; j < n; j++) {
    if (a[j - 1] < a[j]) {
      ans = false;
      break;
    }
  }
  if (ans)
    cout << "YES";
  else
    cout << "NO";
  cout << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  for (long long int i = 1; i <= T; i++) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
}
