#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long i, flag = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] < arr[i - 1]) {
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    for (unsigned long long j = i; j < n; j++) {
      if (arr[j] > arr[j - 1]) {
        cout << "NO"
             << "\n";
        return 0;
      }
    }
  }
  cout << "YES"
       << "\n";
}
