class Xxx attr_accessor :answer def initialize end def set_inputs @n = gets.chomp.to_i @block_lens = gets.chomp.split(" ").map{|n| n.to_i} end def execute @sorting = [] @prev = nil @block_lens.each do |n| if @prev.nil? @prev = n next end if @prev > n @sorting << n else @prev = n end end @answer = @sorting.size end end if $0 == __FILE__ ins = Xxx.new ins.set_inputs ins.execute puts ins.answer end