n = gets.chomp.to_i
h = gets.chomp.split(' ').map(&:to_i)
result = true
if n >= 3
  1.upto(n - 2) do |i|
    break unless result
    h0, h1, h2 = h[i - 1], h[i], h[i + 1]
    h1 = h1 - 1 if h1 >= 2 && h0 < h1
    result = false if h1 - h2 >= 1 || h0 - h1 >= 1
    h[i] = h1
    h[i + 1] = h2
  end
elsif n == 2
  h1, h2 = h[0], h[1]
  h1 = h1 - 1 if h1 >= 2
  result = false if h1 - h2 >= 1
end
puts result ? 'YES' : 'NO'