#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> vfdafdasf;
  deque<int> temp, al_nostru, sortat, v;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  temp = v;
  sort(v.begin(), v.end());
  sortat = v;
  v = temp;
  {
    int ind = 0;
    for (int i = 0; i < v.size() - 1; i++) {
      if (v[i] > v[i + 1] + 1 || v[i] + 1 < (i - 1 < 0 ? 0 : v[i - 1]))
        return cout << "NO", 0;
    }
  }
  cout << "YES";
  return 0;
}
