#include <bits/stdc++.h>
using namespace std;
int f[366], m[366], sum;
long long checkbit(long long n, long long k) { return (n & (1LL << k)); }
bool comp(string a, string b) {
  if (a.size() >= b.size())
    return false;
  else
    return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int aa = 0, bb = 0, cnt = 0;
  int ar[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (int i = 0; i + 1 < n; i++) {
    if (ar[i] < ar[i + 1]) cnt++;
  }
  for (int i = cnt; i + 1 < n; i++) {
    if (ar[i] == ar[i + 1]) cnt++;
  }
  for (int i = cnt; i + 1 < n; i++) {
    if (ar[i] > ar[i + 1]) cnt++;
  }
  if (cnt == n - 1) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
