#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  int max = 0;
  int mi = 0;
  for (int i = 0; i < n; ++i) {
    int temp;
    cin >> temp;
    v.push_back(temp);
    if (temp > max) {
      max = temp;
      mi = i;
    }
  }
  for (int i = 0; i < mi; ++i) {
    if (v[i + 1] <= v[i]) {
      if (v[i] == v[i + 1] && v[i + 1] == max) continue;
      cout << "NO";
      return 0;
    }
  }
  for (int i = n - 1; i > mi; i--) {
    if (v[i] >= v[i - 1]) {
      if (v[i] == v[i - 1] && v[i - 1] == max) continue;
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
