#include <bits/stdc++.h>
using namespace std;
void fuck() {
  int_fast64_t n, a, b, c, i, j;
  a = b = c = j = 0;
  cin >> n;
  int_fast64_t arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 1; i < n; i++) {
    if (arr[i - 1] < arr[i]) {
      a++;
      if (b or c) j++;
    } else if (arr[i - 1] == arr[i]) {
      b++;
      if (c) j++;
    } else if (arr[i - 1] > arr[i])
      c++;
  }
  if (j)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
int main() {
  int_fast64_t t, n;
  t = 1;
  while (t--) {
    fuck();
  }
  return 0;
}
