#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int maxm = 1e4 + 10;
const long long mod = 1e9 + 7;
int a[maxn], n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int pos = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] == n) pos = i;
  }
  for (int i = pos - 1; i >= 1; --i) {
    if (a[i] > a[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for (int i = pos + 1; i <= n; ++i) {
    if (a[i] > a[i - 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
