#include <bits/stdc++.h>
using namespace std;
bool check(vector<long long> a) {
  for (long long i = 0; i < a.size() - 1; i++)
    if (a[i] != -1 && a[i + 1] != -1 && abs(a[i] - a[i + 1]) >= 2) return false;
  return true;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) {
    if (!check(a)) {
      cout << "NO";
      return 0;
    }
    long long _max = 0;
    long long id = -1;
    for (long long j = 0; j < n; j++) {
      if (a[j] > _max) {
        _max = a[j];
        id = j;
      }
    }
    a[id] = -1;
  }
  cout << "YES";
  return 0;
  return 0;
}
