#include <bits/stdc++.h>
using namespace std;
int arr[100010];
int main() {
  int n;
  cin >> n;
  int mx = 0;
  int lst = -1, fst = n - 1;
  if (n == 1) {
    cout << "YES\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mx = max(mx, arr[i]);
  }
  for (int i = 0; i < n; i++) {
    if (arr[i] == mx) {
      fst = min(fst, i);
      lst = max(lst, i);
    }
  }
  for (int i = fst; i <= lst; i++) {
    if (arr[i] != mx) {
      cout << "NO\n";
      return 0;
    }
  }
  for (int i = 1; i < fst; i++) {
    if (arr[i] <= arr[i - 1]) {
      cout << "NO\n";
      return 0;
    }
  }
  for (int i = lst + 1; i < n; i++) {
    if (arr[i] >= arr[i - 1]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}
