#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 5;
const int mod = 1000000007;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
vector<int> v1, v2;
int a[N];
map<int, int> mp;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j, n, m, k, d, x, y, z;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int flag = 1;
  for (int i = 1; i < n - 1; i++) {
    if (a[i] <= a[i - 1] && a[i] <= a[i + 1]) flag = -1;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] == a[i - 1]) flag = -1;
  }
  if (flag == -1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
