#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, i, m, pos;
  cin >> n;
  vector<int> a(n);
  for (i = 0; i < n; ++i) cin >> a[i];
  m = a[0];
  pos = 0;
  for (i = 1; i < n; ++i) {
    if (m < a[i]) {
      m = a[i];
      pos = i;
    }
  }
  for (i = pos - 1; i > -1; --i) {
    if (a[i] > a[i + 1]) break;
  }
  if (i == -1) {
    for (i = pos + 1; i < n; ++i) {
      if (a[i] > a[i - 1]) break;
    }
    if (i == n)
      cout << "Yes";
    else
      cout << "No";
  } else
    cout << "No";
  return 0;
}
