#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MOD = 1e9 + 7;
const int MAX = 1e-9;
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void input(int *a, int size) {
  for (int i = 0; i < size; ++i) {
    cin >> a[i];
  }
}
void output(int *a, int size) {
  for (int i = 0; i < size; ++i) {
    cout << a[i] << " ";
  }
  cout << endl;
}
int main() {
  int n, Max = 0;
  cin >> n;
  stack<int> result;
  queue<int> A;
  int a;
  queue<int> B;
  cin >> a;
  for (int i = 0; i < n - 1; i++) {
    if (Max < a) Max = a;
    A.push(a);
    cin >> a;
    if (abs(a - A.back()) > 1) return cout << "NO", 0;
  }
m:
  int k = 1;
  while (!A.empty()) {
    if (A.front() == Max && k) {
      k = 0;
      result.push(A.front());
      A.pop();
      continue;
    }
    B.push(A.front());
    A.pop();
  }
  if (A.empty()) return cout << "YES", 0;
  Max = 0;
  a = B.front();
  B.pop();
  while (!B.empty()) {
    if (a > Max) Max = a;
    A.push(a);
    if (abs(a - B.front()) > 1) {
      return cout << "NO", 0;
    }
    a = B.front();
    B.pop();
  }
  A.push(a);
  goto m;
}
