    def hoge
      n = gets.to_i
      h = gets.split.map(&:to_i)
      h << Float::INFINITY
      flag = false
      n.times do |i|
        if h[i+1] < h[i]
          if flag
            puts 'No'
            return
          else
            flag = true
          end
        elsif h[i+1] > h[i]
          flag = false
        end
      end
      puts 'Yes'
    end
     
    hoge