#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  while (cin >> n) {
    vector<long long> v;
    v.clear();
    long long u;
    for (int i = 0; i < n; ++i) {
      cin >> u;
      v.push_back(u);
    }
    long long ind = 0;
    while (ind + 1 < n && v[ind + 1] > v[ind]) ind++;
    int sv = ind;
    while (ind < n && v[ind] == v[sv]) ind++;
    bool flag = true;
    for (int i = ind; i < n; ++i) {
      if (i > 0 && v[i] >= v[i - 1]) flag = false;
    }
    cout << (flag ? "YES" : "NO") << endl;
  }
  return 0;
}
