program name
    implicit none
    integer(4):: n,t,i,nmin,nmax,cnt
    integer(4),allocatable:: a(:), p(:)

    read*, n,t
    allocate(a(n),p(n))
    read*, a(:)
    nmin = maxval(a)
    nmax=0
    do i=1,n
        nmin = min(nmin,a(i))
        p(i) = a(i)-nmin
        nmax = max(nmax,p(i))
    end do

    cnt=0
    do i=1,n
        if (p(i) == nmax) cnt=cnt+1
    end do
    print*, cnt
end program name