#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long cnt = 0;
  long long f = 0, g = 0, h = 0, flag = 0;
  for (long long i = 0; i < n - 1; i++) {
    if (a[i] < a[i + 1]) f = 1;
    if (a[i] == a[i + 1]) g = 1;
    if (a[i] > a[i + 1]) h = 1;
    if (g) {
      if (a[i] < a[i + 1]) flag = 1;
    }
    if (h) {
      if (a[i] < a[i + 1] || a[i] == a[i + 1]) flag = 1;
    }
  }
  if (flag)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
