#include <bits/stdc++.h>
using namespace std;
bool isValid(vector<long long> v, long long size) {
  for (long long i = 0; i < size - 1; ++i)
    if (abs(v[i] - v[i + 1]) >= 2) return false;
  return true;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> v;
  v.resize(n);
  for (long long i = 0; i < n; ++i) {
    cin >> v[i];
  }
  long long j = n;
  bool ok = true;
  while (j > 0 && ok) {
    ok = ok && isValid(v, j);
    long long maxIdx = 0;
    for (long long i = 0; i < j; ++i) {
      if (v[maxIdx] < v[i]) maxIdx = i;
    }
    long long buf = v[maxIdx];
    for (long long i = maxIdx; i < n - 1; ++i) v[i] = v[i + 1];
    v[n - 1] = buf;
    --j;
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}
