if __FILE__ == $0 size = gets.to_i seq = gets.split(" ").map(&:to_i) count = 0 1.upto(size-1) do |i| 0.upto(i-1) do |j| if seq[i] < seq[j] count += 1 break end end end p size - (size - count) end