#include <bits/stdc++.h>
using namespace std;
int n, i, x, xx, st;
int main() {
  cin >> n >> x;
  for (i = 2; i <= n; i++) {
    cin >> xx;
    if (st == 0) {
      if (xx < x) st = 2;
      if (xx == x) st = 1;
      x = xx;
    } else if (st == 1) {
      if (xx > x) {
        cout << "NO";
        return 0;
      }
      if (xx < x) st = 2;
      x = xx;
    } else if (st == 2) {
      if (xx >= x) {
        cout << "NO";
        return 0;
      }
      x = xx;
    }
  }
  cout << "YES";
  return 0;
}
