#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int *mx = max_element(a, a + n);
  int ind = 0;
  for (long long int i = 0; i < n; i++) {
    if (a[i] == *mx) ind = i;
  }
  int k = ind - 1;
  int j = ind + 1;
  for (long long int i = j; i < n; i++) {
    if (a[i] > a[i - 1]) {
      cout << "NO" << endl;
      return;
      break;
    }
  }
  for (int i = k; i >= 0; i--) {
    if (a[i] > a[i + 1]) {
      cout << "NO" << endl;
      return;
      break;
    }
  }
  cout << "YES" << endl;
}
int main() {
  long long int t = 1;
  while (t-- > 0) {
    solve();
  }
}
