#include <bits/stdc++.h>
int power(int x, int y) {
  int res = 1;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
int ncr(int n, int r) {
  int res = 1;
  if (r > n - r) r = n - r;
  for (int i = 0; i < r; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int lcm(int a, int b) { return (a / gcd(a, b) * b); }
int max(int a, int b) {
  int ans = a > b ? a : b;
  return ans;
}
using namespace std;
int main() {
  unsigned long long int n;
  cin >> n;
  unsigned long long int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i < n - 1; ++i) {
    if (a[i] < a[i - 1] && a[i] < a[i + 1]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
