#include <bits/stdc++.h>
using namespace std;
inline long long uscan() {
  long long n = 0, c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c <= '9' && c >= '0') {
    n = n * 10 + c - '0';
    c = getchar();
  }
  return n;
}
int main() {
  int i;
  int n = uscan();
  vector<int> a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b = a;
  bool we = 1;
  int count = 0;
  int N = n;
  while (we) {
    count++;
    if (count > 50) break;
    for (i = 0; i < n - 1; i++) {
      if (a[i] - a[i + 1] >= 2) {
        a[i]--;
        a[i + 1]++;
        i++;
      }
    }
    int maxi = 0;
    for (i = 0; i < N; i++) {
      maxi = max(a[i], maxi);
    }
    int pos = 0;
    for (i = 0; i < N; i++)
      if (a[i] == maxi) {
        pos = i;
        break;
      }
    for (i = pos; i < N; i++) {
      a[i] = a[i + 1];
    }
    a[N - 1] = maxi;
    N--;
    bool we2 = 1;
    for (i = 0; i < n - 1; i++) {
      if (a[i + 1] < a[i]) we2 = 0;
    }
    if (we2) break;
  }
  sort(b.begin(), b.end());
  if (b != a) {
    cout << "NO";
  } else {
    cout << "YES";
  }
  return 0;
}
