#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, i = 1;
  cin >> n >> a;
  b = 0;
  while ((b < a) and (i < n)) {
    b = a;
    cin >> a;
    i++;
  }
  if (a == b) {
    while ((b == a) and (i < n)) {
      b = a;
      cin >> a;
      i++;
    }
    if (b < a) {
      cout << "NO";
      return 0;
    }
  }
  if (a < b) {
    while ((b > a) and (i < n)) {
      b = a;
      cin >> a;
      i++;
    }
    if (b <= a) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
