#include <bits/stdc++.h>
using namespace std;
vector<int>::iterator get_max_element_index(vector<int>& v) {
  int max_el = INT_MIN;
  vector<int>::iterator max_ind = v.begin();
  for (auto it = v.begin(); it != v.end(); it++) {
    if (*it > max_el) {
      max_el = *it;
      max_ind = it;
    }
  }
  return max_ind;
}
bool check(vector<int>& v) {
  for (int i = 1; i < v.size(); i++) {
    if (abs(v[i] - v[i - 1]) >= 2) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  vector<int> v(n), op(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    op[i] = v[i];
  }
  sort(op.begin(), op.end());
  if (!check(op) or !check(v)) {
    cout << "NO\n";
    return 0;
  }
  while (v.size()) {
    auto max_el_ind = get_max_element_index(v);
    v.erase(max_el_ind);
    if (!check(v)) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
