#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int n;
bool check() {
  for (int i = 1; i < n; i++) {
    if (abs(a[i - 1] - a[i]) >= 2) return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (check()) {
    cout << "NO";
    return 0;
  }
  int last = -1;
  for (int i = 0; i < n; i++) {
    int mx = -1, mxj = 0;
    for (int j = 0; j < n; j++) {
      if (mx < a[j]) {
        mx = a[j];
        mxj = j;
      }
    }
    if (last == -1) last = mx;
    if (mx == -1) break;
    if (abs(last - mx) >= 2) {
      cout << "NO";
      return 0;
    }
    a[mxj] = -1;
    last = mx;
  }
  cout << "YES";
}
