#include <bits/stdc++.h>
using namespace std;
const long long infl = 1e18 + 5;
long long int n, m, k, q, x, y, mx = -1, mn = infl, f, val, sz, sm, cnt, ans,
                                t = 1, i, j, ind = -1;
long long int a[1000004];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("inp.txt", "r")) {
    freopen("myfile.txt", "w", stdout);
    freopen("inp.txt", "r", stdin);
  }
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n - 1; i++) {
    if (f == 0) {
      if (a[i + 1] < a[i]) {
        f = 2;
      } else if (a[i + 1] == a[i]) {
        f = 1;
      }
    } else if (f == 1) {
      if (a[i + 1] > a[i]) {
        ans = -1;
        break;
      }
      if (a[i + 1] < a[i]) {
        f = 2;
      }
    } else if (f == 2) {
      if (a[i + 1] >= a[i]) {
        ans = -1;
        break;
      }
    }
  }
  if (ans == -1) {
    cout << "NO";
  } else
    cout << "YES";
  return 0;
}
