#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long i = 0;
  long long mx = 0;
  long long pos = 0;
  for (; i < n; i++) {
    cin >> a[i];
    if (a[i] > mx) mx = a[i], pos = i;
  }
  i = pos;
  bool ans = true;
  for (; i > 0; i--)
    if (a[i] < a[i - 1]) {
      ans = false;
      break;
    }
  i = pos;
  for (; i < n - 1; i++)
    if (a[i] < a[i + 1]) {
      ans = false;
      break;
    }
  cout << (ans ? "YES" : "NO");
}
