#include <bits/stdc++.h>
using namespace std;
int pillars[500050];
int main() {
  int n;
  cin >> n;
  int nr = 0;
  for (int i = 1; i <= n; i++) cin >> pillars[i];
  for (int i = 0; i <= n + 1; i++)
    if (pillars[i] >= pillars[i - 1] && pillars[i] >= pillars[i + 1]) nr++;
  if (nr > 1)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
