#include <bits/stdc++.h>
using namespace std;
void solveFunction() {
  int n;
  cin >> n;
  vector<int> v(n);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[mx] < v[i]) mx = i;
  }
  int prev = v[mx];
  for (int i = mx - 1; i >= 0; i--) {
    if (v[i] > prev) {
      cout << "No\n";
      return;
    }
    prev = v[i];
  }
  prev = v[mx];
  for (int i = mx + 1; i < n; i++) {
    if (v[i] > prev) {
      cout << "No\n";
      return;
    }
    prev = v[i];
  }
  cout << "Yes\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    solveFunction();
  }
}
