#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  ;
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    bool fine = true, incst = -1;
    for (int j = 1; j < a.size(); j++) {
      if (a[j - 1] <= a[j] - 2 || a[j - 1] - 2 >= a[j]) {
        fine = false, incst = j;
      }
    }
    if (!fine) {
      cout << "NO\n";
      return 0;
    }
    int v = 0, p = -1;
    for (int j = 0; j < a.size(); j++)
      if (a[j] > v) v = a[j], p = j;
    ans.push_back(v);
    auto it = a.begin();
    advance(it, p);
    a.erase(it);
  }
  cout << "YES\n";
  return 0;
}
