#include <bits/stdc++.h>
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-9;
using namespace std;
int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dc[] = {0, 1, 0, -1, -1, 1, -1, 1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int d[n + 10], i;
  for (i = 0; i <= n - 1; i++) cin >> d[i];
  for (i = 1; i <= n - 2; i++)
    if (d[i] <= d[i + 1] && d[i] <= d[i - 1]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  return 0;
}
