#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 100;
int a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int index;
  for (index = 1; index < n; ++index) {
    if (a[index] <= a[index - 1]) break;
  }
  for (; index < n; ++index) {
    if (a[index] != a[index - 1]) break;
  }
  for (; index < n; ++index) {
    if (a[index] >= a[index - 1]) break;
  }
  if (index == n) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
