#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 121;
int a[MAX_N], b[MAX_N], n;
inline bool f() {
  for (int i = 1; i <= n; ++i)
    if (a[i] != b[i]) return 0;
  return 1;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  while (n > 0) {
    int posMax = 0;
    for (int i = 1; i <= n; ++i) {
      if (i + 1 <= n) {
        if (abs(a[i] - a[i + 1]) > 1) return cout << "NO\n", 0;
      }
      if (a[i] > a[posMax]) posMax = i;
    }
    while (posMax < n) {
      swap(a[posMax], a[posMax + 1]);
      ++posMax;
    }
    --n;
  }
  cout << "YES\n";
  return 0;
}
