#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, i, j, k, l, n, m, arr[100001],
      Min = 9999999999999, Max = 0, _count = 0, sum = 0, cons = 0, inc = 1,
      dec = 0;
  cin >> n;
  for (int i = (int)0; i < int(n); i++) {
    cin >> arr[i];
  }
  for (int i = (int)0; i < int(n - 1); i++) {
    if (arr[i] == arr[i + 1]) cons = 1;
    if (arr[i] == arr[i + 1] && dec) {
      cout << "NO" << endl;
      return 0;
    }
    if (arr[i] < arr[i + 1]) {
      if (dec || cons) {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (arr[i] > arr[i + 1]) dec = 1;
  }
  cout << "YES" << endl;
  return 0;
}
