#include <bits/stdc++.h>
using namespace std;
const long long N = 1e12;
int fexp(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % 998244353;
    b /= 2;
    a = a * a % 998244353;
  }
  return ans;
}
int inverse(int a, int p) { return fexp(a, p - 2); }
void solve() { return; }
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long k_ = 0; k_ < n; k_++) {
    cin >> v[k_];
  };
  bool g = 0;
  for (long long i = 1; i < n - 1; i++) {
    if (v[i] < v[i + 1] && v[i] < v[i - 1]) {
      g = 1;
      cout << "NO";
      break;
    }
  }
  if (!g) {
    cout << "YES";
  }
  return 0;
}
