#!/bin/ruby n = gets.strip.to_i height = gets.strip height = height.split(' ').map(&:to_i) max = -1 num_max = 0 height.each do |c| if c > max max = c num_max = 1 elsif c == max num_max += 1 end end puts(num_max)