#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
long long co[maxn];
string str;
long long n, m, k, t, maxx = 0, ans = 0;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  bool flag = 0, flag2 = 1;
  for (int i = 1; i <= n; i++) cin >> co[i];
  for (int i = 1; i <= n; i++) {
    for (int k = 1; k <= n; k++) {
      if (i > k) continue;
      flag2 = 1;
      for (int j = 1; j <= i; j++) {
        if (co[j] <= co[j - 1]) flag2 = 0;
      }
      for (int j = i + 1; j <= k; j++)
        if (co[j] != co[j - 1]) flag2 = 0;
      for (int j = k + 1; j <= n; j++)
        if (co[j] >= co[j - 1]) flag2 = 0;
      if (flag2) flag = 1;
    }
  }
  if (flag)
    cout << "YES";
  else
    cout << "NO";
}
