#include <bits/stdc++.h>
using namespace std;
bool malo(vector<int> &v) {
  for (int i = 1; i < v.size(); i++)
    if (abs(v[i] - v[i - 1]) >= 2) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  if (malo(v)) {
    cout << "NO" << endl;
    return 0;
  }
  while (v.size()) {
    int grande = 0;
    for (int i = 0; i < v.size(); i++)
      if (v[i] > v[grande]) grande = i;
    v.erase(v.begin() + grande);
    if (v.size() && malo(v)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
