#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> ravioli(n);
  for (int i = 0; i < n; ++i) cin >> ravioli[i];
  while (!ravioli.empty()) {
    for (int i = 0; i + 1 < ravioli.size(); ++i) {
      if (abs(ravioli[i] - ravioli[i + 1]) > 1) {
        cout << "NO\n";
        return 0;
      }
    }
    int x = *max_element(ravioli.begin(), ravioli.end());
    for (int i = 0; i < ravioli.size(); ++i) {
      if (ravioli[i] == x) {
        ravioli.erase(ravioli.begin() + i);
        break;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
