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