n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)
def f(a)
  cnt=0
  last = max = a.last
  (a.length - 1).downto(1) do |i|
    if (a[i] - last) > 1 then
      puts "No"
      exit
    else
      if (a[i]-max) >0 then
        cnt+=1
        max = a[i]
      end
      if cnt > 1 then
        puts "No"
        exit
      end
    end
  end
end

if h.each_cons(2).all? {|a, b| a <= b } or h.length < 2 then
  puts "Yes"
else
  f(h)
  puts "Yes"
end