#include <bits/stdc++.h>
using namespace std;
bool vowel(char a) {
  a = toupper(a);
  if ((a == 'A') || (a == 'E') || (a == 'I') || (a == 'O') || (a == 'U'))
    return 1;
  return 0;
}
long long int n, m, q, a, b, c, sum = 0, cnt = 0;
long long int arr[500055];
map<long long int, bool> mp;
string str;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  bool one = 1, two = 1, tr = 1;
  for (int i = 0; i < n; i++) {
    if (arr[i] > arr[i - 1]) {
      if (!tr || !two) {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (arr[i] == arr[i - 1]) {
      two = 0;
      if (tr)
        continue;
      else {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (arr[i] < arr[i - 1]) {
      tr = 0;
    }
  }
  cout << "YES" << endl;
}
