n = gets.chomp.to_i
ary = gets.chomp.split().map(&:to_i)

diff_ary = (ary.size - 1).times.map.with_index {|i,idx| [ary[i+1] - ary[i],idx]}
if diff_ary.any?{|diff| diff.first < -1}
  puts "No"
else
  # 最初のifで-2以下のdiffは無くなっている。
  minus_diff_ary_idx = diff_ary.select{|diff| diff.first == -1}.map(&:last)
  plus_diff_ary_idx = diff_ary.select{|diff| diff.first > 0}.map(&:last)
  if minus_diff_ary_idx.size == 0 ||
    n == 1 ||
    (minus_diff_ary_idx.size - 1).times.all? do |i|
      plus_diff_ary_idx.any? do |p_idx|
        minus_diff_ary_idx[i] < p_idx &&
        p_idx < minus_diff_ary_idx[i+1]
      end
    end
    puts "Yes"
  else
    puts "No"
  end
end