#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
int a[110];
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  int n, maxx = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], maxx = max(maxx, a[i]);
  int l = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == maxx) l = i;
  }
  for (int i = 2; i <= l; i++) {
    if (a[i] < a[i - 1]) {
      cout << "NO";
      return 0;
    }
    if (a[i] == a[i - 1] && a[i] != maxx) {
      cout << "NO";
      return 0;
    }
  }
  for (int i = l + 1; i <= n; i++) {
    if (a[i - 1] < a[i]) {
      cout << "NO";
      return 0;
    }
    if (a[i] == a[i - 1]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
