from collections import Counter



n,t=list(map(int,input().split()))

*a,=list(map(int,input().split()))



m=[None]*n

used=[False]*n



for i in range(n)[::-1]:

    if i==n-1:

        m[i]=a[i]

    else:

        m[i]=max(m[i+1],a[i])



c=Counter([m[i]-a[i] for i in range(n)])

print((c[max(c.keys())]))

from operator import add

from collections import defaultdict



class SegTree():

    def __init__(self, N, e, operator_func=add):

        self.e = e # 単位元

        self.size = N

        self.node = [self.e] * (2*N)

        self.operator_func = operator_func # 処理(add or xor max minなど)



    def set_list(self, l):

        for i in range(self.size):

            self.node[i+self.size-1] = l[i]

        for i in range(self.size-1)[::-1]:

            self.node[i] = self.operator_func(self.node[2*i+1], self.node[2*i+2])

    

    def update(self, k, x):

        k += self.size-1

        self.node[k] = x

        while k >= 0:

            k = (k - 1) // 2

            self.node[k] = self.operator_func(self.node[2*k+1], self.node[2*k+2])



    def get(self, l, r):

        # [l, r) についてqueryを求める

        x = self.e

        l += self.size

        r += self.size



        while l<r:

            if l&1:

                x = self.operator_func(x, self.node[l-1])

                l += 1

            if r&1:

                r -= 1

                x = self.operator_func(x, self.node[r-1])

            l >>= 1

            r >>= 1

        return x



N, T = list(map(int, input().split()))

*A, = list(map(int, input().split()))

tree = SegTree(N, 0, max)

tree.set_list(A)

d = defaultdict(int)

for i in range(N-1):

    d[(tree.get(i+1, N)-A[i])] += 1

print((d[max(d.keys())]))
from collections import Counter

n, t = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
m = [None] * n
used = [False] * n
for i in range(n)[::-1]:
    if i == n - 1:
        m[i] = a[i]
    else:
        m[i] = max(m[i + 1], a[i])
c = Counter([m[i] - a[i] for i in range(n)])
print((c[max(c.keys())]))

from operator import add
from collections import defaultdict


class SegTree:
    def __init__(self, N, e, operator_func=add):
        self.e = e  # 単位元
        self.size = N
        self.node = [self.e] * (2 * N)
        self.operator_func = operator_func  # 処理(add or xor max minなど)

    def set_list(self, l):
        for i in range(self.size):
            self.node[i + self.size - 1] = l[i]
        for i in range(self.size - 1)[::-1]:
            self.node[i] = self.operator_func(
                self.node[2 * i + 1], self.node[2 * i + 2]
            )

    def update(self, k, x):
        k += self.size - 1
        self.node[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.node[k] = self.operator_func(
                self.node[2 * k + 1], self.node[2 * k + 2]
            )

    def get(self, l, r):
        # [l, r) についてqueryを求める
        x = self.e
        l += self.size
        r += self.size
        while l < r:
            if l & 1:
                x = self.operator_func(x, self.node[l - 1])
                l += 1
            if r & 1:
                r -= 1
                x = self.operator_func(x, self.node[r - 1])
            l >>= 1
            r >>= 1
        return x


N, T = list(map(int, input().split()))
(*A,) = list(map(int, input().split()))
tree = SegTree(N, 0, max)
tree.set_list(A)
d = defaultdict(int)
for i in range(N - 1):
    d[(tree.get(i + 1, N) - A[i])] += 1
print((d[max(d.keys())]))

-from collections import Counter +from operator import add +from collections import defaultdict -n, t = list(map(int, input().split())) -(*a,) = list(map(int, input().split())) -m = [None] * n -used = [False] * n -for i in range(n)[::-1]: -    if i == n - 1: -        m[i] = a[i] -    else: -        m[i] = max(m[i + 1], a[i]) -c = Counter([m[i] - a[i] for i in range(n)]) -print((c[max(c.keys())])) + +class SegTree: +    def __init__(self, N, e, operator_func=add): +        self.e = e  # 単位元 +        self.size = N +        self.node = [self.e] * (2 * N) +        self.operator_func = operator_func  # 処理(add or xor max minなど) + +    def set_list(self, l): +        for i in range(self.size): +            self.node[i + self.size - 1] = l[i] +        for i in range(self.size - 1)[::-1]: +            self.node[i] = self.operator_func( +                self.node[2 * i + 1], self.node[2 * i + 2] +            ) + +    def update(self, k, x): +        k += self.size - 1 +        self.node[k] = x +        while k >= 0: +            k = (k - 1) // 2 +            self.node[k] = self.operator_func( +                self.node[2 * k + 1], self.node[2 * k + 2] +            ) + +    def get(self, l, r): +        # [l, r) についてqueryを求める +        x = self.e +        l += self.size +        r += self.size +        while l < r: +            if l & 1: +                x = self.operator_func(x, self.node[l - 1]) +                l += 1 +            if r & 1: +                r -= 1 +                x = self.operator_func(x, self.node[r - 1]) +            l >>= 1 +            r >>= 1 +        return x + + +N, T = list(map(int, input().split())) +(*A,) = list(map(int, input().split())) +tree = SegTree(N, 0, max) +tree.set_list(A) +d = defaultdict(int) +for i in range(N - 1): +    d[(tree.get(i + 1, N) - A[i])] += 1 +print((d[max(d.keys())]))