#include <bits/stdc++.h>
using namespace std;
int n;
int arr[1000005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int up = 1;
  for (int i = 0; i < (n - 1); i++) {
    if (up) {
      up = (arr[i] < arr[i + 1]);
    } else if (arr[i] < arr[i + 1]) {
      cout << "NO" << endl;
      exit(0);
    }
  }
  cout << "YES" << endl;
}
