#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
vector<long long> t;
void build(vector<long long> &a, long long v, long long tl, long long tr) {
  if (tl == tr) {
    t[v] = a[tl];
  } else {
    long long tm = (tl + tr) / 2;
    build(a, 2 * v, tl, tm);
    build(a, 2 * v + 1, tm + 1, tr);
    t[v] = t[2 * v] + t[2 * v + 1];
  }
}
void update(long long v, long long tl, long long tr, long long pos,
            long long value) {
  if (tl == tr) {
    t[v] = value;
  } else {
    long long tm = (tl + tr) / 2;
    if (pos <= tm) {
      update(2 * v, tl, tm, pos, value);
    } else {
      update(2 * v + 1, tm + 1, tr, pos, value);
    }
    t[v] = t[2 * v] + t[2 * v + 1];
  }
}
long long sum(long long v, long long tl, long long tr, long long l,
              long long r) {
  if (r < l) return 0;
  if (tl == l && tr == r) {
    return t[v];
  }
  long long tm = (tl + tr) / 2;
  return sum(2 * v, tl, tm, l, min(r, tm)) +
         sum(2 * v + 1, tm + 1, tr, max(l, tm + 1), r);
}
void sieveOfEratosthenes(long long N, vector<long long> &s) {
  vector<bool> prime(N + 1, false);
  for (long long i = 2; i <= N; i += 2) s[i] = 2;
  for (long long i = 3; i <= N; i += 2) {
    if (prime[i] == false) {
      s[i] = i;
      for (long long j = i; j * i <= N; j += 2) {
        if (prime[i * j] == false) {
          prime[i * j] = true;
          s[i * j] = i;
        }
      }
    }
  }
}
long long min_(long long a, long long b, long long c) {
  return min(a, min(b, c));
}
void dfs(long long u, vector<vector<long long>> &graph,
         vector<long long> &visited) {
  visited[u] = 1;
  for (long long i = 0; i < graph[u].size(); i++) {
    if (visited[graph[u][i]] == 0) {
      dfs(graph[u][i], graph, visited);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, num = 0, ind;
  cin >> n;
  vector<long long> v(n);
  for (i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] > num) {
      num = v[i];
      ind = i;
    }
  }
  for (i = ind + 1; i < n; i++) {
    if (v[i] >= v[i - 1]) {
      cout << "No";
      return 0;
    }
  }
  for (i = ind - 1; i >= 0; i--) {
    if (v[i] >= v[i + 1]) {
      cout << "No";
      return 0;
    }
  }
  cout << "YES";
}
