N = gets.to_i
H = gets.split.map(&:to_i)

decrease = {}

0.upto(N - 2) do |idx|
  if H[idx] > H[idx + 1]
    if decrease[idx - 1]
      puts 'No'
      exit
    else
      decrease[idx] = true
    end
  end
end

puts 'Yes'
