#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x, y;
  cin >> x;
  int c = 1;
  bool ch = true;
  for (int i = 0; i < n - 1; i++) {
    cin >> y;
    if (y > x) {
      if (c != 1) ch = false;
    } else if (x == y) {
      if (c > 2) {
        ch = false;
      } else
        c = 2;
    } else if (x > y) {
      c = 3;
    }
    x = y;
  }
  if (ch)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
