#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int& i : v) {
    cin >> i;
  }
  bool was = false;
  for (int i = 1; i < n; ++i) {
    if (v[i] < v[i - 1])
      was = true;
    else if (v[i] > v[i - 1] && was == true) {
      cout << "No\n";
      exit(0);
    }
  }
  cout << "Yes\n";
}
