#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 1;
int a[N];
int main() {
  vector<int> v;
  int t, x, y;
  scanf("%d", &t);
  scanf("%d", &y);
  x = y;
  t--;
  while (t--) {
    scanf("%d", &y);
    v.push_back((y > x) ? 1 : (x == y) ? 0 : -1);
    x = y;
  }
  if (v.size() >= 2)
    for (int i = 0; i < v.size() - 1; i++)
      if (v[i] < v[i + 1]) {
        puts("NO");
        return 0;
      } else if (v.size() == 1)
        if (v[0] < 0) {
          puts("NO");
          return 0;
        }
  puts("YES");
  return 0;
}
