#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, i;
  vector<int> arr, sol, orig;
  cin >> n;
  arr.resize(n);
  for (i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  orig = arr;
  sort(orig.begin(), orig.end());
  for (i = 0; i < n; ++i) {
    for (int k = 0; k + 1 < arr.size(); ++k) {
      while (arr[i] - arr[i + 1] >= 2) ++arr[i + 1], --arr[i];
      while (arr[i] - arr[i + 1] <= -2) --arr[i + 1], ++arr[i];
    }
    int j = -1, x = -1;
    for (int k = 0; k < arr.size(); ++k) {
      if (arr[k] > x) {
        x = arr[k];
        j = k;
      }
    }
    sol.push_back(arr[j]);
    arr.erase(arr.begin() + j);
  }
  reverse(sol.begin(), sol.end());
  cout << (sol == orig ? "YES" : "NO") << '\n';
}
