#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
set<pair<int, int> > s;
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int first;
    cin >> first;
    s.insert(pair<int, int>(i, first));
  }
  for (int i = 1; i < n; i++) {
    auto it = s.begin();
    int p = it->second;
    it++;
    while (it != s.end()) {
      if (abs(it->second - p) >= 2) {
        printf("NO\n");
        return 0;
      }
      p = it->second;
      it++;
    }
    pair<int, int> del = pair<int, int>(0, 0);
    for (pair<int, int> first : s)
      if (first.second > del.second) del = first;
    s.erase(del);
  }
  printf("YES\n");
}
