#include <bits/stdc++.h>
using namespace std;
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;
}
