#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  int b = 0, c = n - 1;
  while (a[b + 1] > a[b] && b < n - 1) {
    b++;
  }
  while (a[c - 1] > a[c] && c > 0) {
    c--;
  }
  int j = b;
  while (a[j] == a[j + 1]) {
    j++;
  }
  if (j == c) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
