#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int y = 0; y < n; y++) {
    cin >> arr[y];
  }
  int maxm = -1;
  int maxInd = -1;
  for (int i = 0; i < n; i++) {
    if (arr[i] > maxm) {
      maxm = arr[i];
      maxInd = i;
    }
  }
  int low = maxInd - 1, high = maxInd + 1, top = maxm, more;
  while (low > -1 && high < n) {
    more = max(arr[low], arr[high]);
    if (more >= top) {
      cout << "NO" << endl;
      return 0;
      break;
    }
    top = more;
    if (more == arr[low])
      low--;
    else
      high++;
  }
  while (low > -1) {
    if (arr[low] > top) {
      cout << "NO" << endl;
      return 0;
    }
    top = arr[low];
    low--;
  }
  while (high < n) {
    if (arr[high] > top) {
      cout << "NO" << endl;
      return 0;
    }
    top = arr[high];
    high++;
  }
  cout << "YES" << endl;
  return 0;
}
