#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 4;
int main() {
  bool inc = false, cons = false, dec = false;
  int n;
  cin >> n;
  int ar[n];
  for (int i = 0; i < n; ++i) {
    cin >> ar[i];
  }
  if (n == 1) {
    cout << "yes\n";
    return 0;
  }
  for (int i = 1; i < n; ++i) {
    if (ar[i] - ar[i - 1] > 0 && (cons || dec)) {
      cout << "NO\n";
      return 0;
    } else if (ar[i] - ar[i - 1] > 0)
      inc = true;
    else if (ar[i] - ar[i - 1] == 0 && dec) {
      cout << "NO\n";
      return 0;
    } else if (ar[i] - ar[i - 1] == 0)
      cons = true;
    else if (ar[i] - ar[i - 1] < 0)
      cons = true, dec = true;
  }
  if (inc && !(cons || dec)) cons = true;
  if (cons)
    cout << "yes\n";
  else
    cout << "no\n";
  return 0;
}
