There are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.
Takahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows:
 - Move: When at town i (i < N), move to town i + 1.
 - Merchandise: Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money.
For some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.)
During the travel, Takahashi will perform actions so that the profit of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel.
Aoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i.
Aoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.

-----Constraints-----
 - 1 ≦ N ≦ 10^5
 - 1 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)
 - A_i are distinct.
 - 2 ≦ T ≦ 10^9
 - In the initial state, Takahashi's expected profit is at least 1 yen.

-----Input-----
The input is given from Standard Input in the following format:
N T
A_1 A_2 ... A_N

-----Output-----
Print the minimum total cost to decrease Takahashi's expected profit by at least 1 yen.

-----Sample Input-----
3 2
100 50 200

-----Sample Output-----
1

In the initial state, Takahashi can achieve the maximum profit of 150 yen as follows:
 - Move from town 1 to town 2.
 - Buy one apple for 50 yen at town 2.
 - Move from town 2 to town 3.
 - Sell one apple for 200 yen at town 3.
If, for example, Aoki changes the price of an apple at town 2 from 50 yen to 51 yen, Takahashi will not be able to achieve the profit of 150 yen. The cost of performing this operation is 1, thus the answer is 1.
There are other ways to decrease Takahashi's expected profit, such as changing the price of an apple at town 3 from 200 yen to 199 yen.

Difficulty: competition

Starter code:

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

cummax = [A[-1]]
for a in reversed(A[:-1]):
    cummax.append(max(cummax[-1], a))
cummax.reverse()

maxgain = n = 0
for buy,sell in zip(A,cummax):
    gain = sell - buy
    if gain > maxgain:
        maxgain = gain
        n = 1
    elif gain == maxgain:
        n += 1
print(n)


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

m = 10**10
M = 0
ans = 1
for x in xs:
    if x < m:
        m = x
    elif x - m == M:
        ans += 1
    elif x - m > M:
        ans = 1
        M = x - m

print(ans)

from sys import stdin
input = stdin.readline
N,T = list(map(int,input().split()))
prices = list(map(int,input().split()))
last = 10000000000
highestTally = [prices[-1]]
highestCount = [1]

for price in prices[-2:-N-1:-1]:
    if price==highestTally[-1]:
        highestCount.append(highestCount[-1]+1)
    else:
        highestCount.append(1)
    highestTally.append(max(highestTally[-1],price))
highestTally.reverse()
highestCount.reverse()

indexOfHighest={}
for i in range(N-1,-1,-1):
    if highestTally[i]==prices[i]:
        indexOfHighest[highestTally[i]]=i

biggestJump=0
sellingPriceForBiggestJump=0
HPcount=0
LPcount=0
HPGroups=[]
LPGroups=[]
for index,price in enumerate(prices):
    if index==N-1:
        break
    bestSellingPrice = highestTally[index+1]
    jump = bestSellingPrice-price
    #print(jump,bestSellingPrice,biggestJump)
    if jump>biggestJump:
        biggestJump = jump
        #LPcount+=1
        LPGroups=[]
        HPGroups=[]
        
        LPGroups.append(1)
        sellingPriceForBiggestJump = bestSellingPrice
        #HPcount=highestCount[indexOfHighest[bestSellingPrice]]
        HPGroups.append(highestCount[indexOfHighest[bestSellingPrice]])
    elif jump==biggestJump:
        if bestSellingPrice!=sellingPriceForBiggestJump:
            sellingPriceForBiggestJump = bestSellingPrice
            #HPcount+=highestCount[indexOfHighest[bestSellingPrice]]
            HPGroups.append(highestCount[indexOfHighest[bestSellingPrice]])
            LPGroups.append(0)
        LPGroups[-1]+=1
count = 0
bs = T//2
for a,b in zip(HPGroups,LPGroups):
    if bs>min(a,b):
        count+=min(a,b)
    else:
        count+=bs
print(count)


#!/usr/bin/env python3
import sys


def solve(N: int, T: int, A: "List[int]"):
    right_max = [0] * N # i番目よりあとで一番大きいA_i
    m_a = 0
    for i in range(1, N):
        m_a = max(m_a, A[-i])
        right_max[-i-1] = m_a

    m_p = 0
    count = 0
    for i, a in enumerate(A):
        profit = right_max[i] - a
        if profit > m_p:
            m_p = profit
            count = 1
        elif profit == m_p:
            count += 1
    print(count)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, T, A)

def __starting_point():
    main()

__starting_point()

import heapq

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

h = []
B = [0]*N

for i in range(N):
    heapq.heappush(h,A[i])
    B[i] = h[0]

j = []
C = [0]*N

for i in range(N-1,-1,-1):
    heapq.heappush(j,-A[i])
    C[i] = -j[0]

B = B[:-1]
C = C[1:]
D = list([C[x]-B[x] for x in range(N-1)])
t = max(D)

s = 0
D.append(0)
for i in range(N-1):
    if D[i] == t and D[i] > D[i+1]:
        s += 1

print(s)


import sys

N, T = list(map(int, sys.stdin.readline().rstrip().split()))

As = []
As = list(map(int, sys.stdin.readline().rstrip().split()))

mins = []
m = 1e10
vs = []
for A in As:
    m = min(m, A)
    vs.append(A - m)
max_v = max(vs)
res = 0
for v in vs:
    if v == max_v:
        res += 1
print(res)



import numpy as np
N, T = list(map(int, input().split()))

cost_list = np.array(list(map(int, input().split())))

max_num = 0
max_profit = 0
max_list = []
max_value = 0
for x in reversed(cost_list[1:]):
    max_value = max(max_value, x)
    max_list.append(max_value)
max_list = list(reversed(max_list))
max_list = np.array(max_list)
res = max_list - cost_list[:-1]

res_max = max(res)

max_num_list = [y for y in res if y == res_max]

print((len(max_num_list)))




#D    高橋君と見えざる手 / An Invisible Hand
N,T = [int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
Max = 0
count = 1
Min = A[0]
for i in range(N):
    if A[i] <= Min :
        Min = A[i]
    else :
        temp = A[i]-Min
        if temp > Max:
            Max = temp 
            count = 1
        elif temp == Max :
            count += 1
print(count)

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

cnt = max_profit = 0
INF = float('inf')
min_cost = INF
for a in A:
    profit = a - min_cost
    if profit == max_profit:
        cnt += 1
    elif profit > max_profit:
        cnt = 1
        max_profit = profit
    min_cost = min(min_cost, a)

print(cnt)

n,_,*a=map(int,open(0).read().split())
m=d=c=0
for t in a[::-1]:
    if t>m:
        m=t
    if m-t>d:
        d=m-t
        c=1
    elif m-t==d:
        c+=1
print(c)

# f = open('input', 'r')
# n, t = map(int, f.readline().split())
# A = list(map(int, f.readline().split()))
n, t = list(map(int, input().split()))
A = list(map(int, input().split()))

ans = 0
max_diff = 0
min_a = A[0]
for a in A:
    min_a = min(min_a, a)
    if (a - min_a) == max_diff:
        ans += 1
    elif (a - min_a) > max_diff:
        ans = 1
        max_diff = (a - min_a)
print(ans)


input_lines = input()
items = input_lines.split()
N = int(items[0])
T = int(items[1])

input_lines = input()
items = input_lines.split()
As = [int(x) for x in items]

def my_func(N, T, As):
    buys = T // 2
    counts = 0
    val_earn = 0
    val_min = 10E10
    for val in As:
        if val < val_min:
            val_min = val
        else:
            diff = val - val_min
            if diff == val_earn:
                counts += 1
            elif diff > val_earn:
                val_earn = diff
                counts = 1
    print(counts)

my_func(N, T, As)

def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, t = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(list)
    min_b = 10 ** 9
    max_p = 0
    for v in a:
        p = v - min_b
        max_p = max(max_p, p)
        d[p] += [min_b]
        min_b = min(min_b, v)
    print((len(d[max_p])))


def __starting_point():
    slove()

__starting_point()

#!/usr/bin/env python
# -*- coding:utf-8 -*-



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

maxA = [0] * N
minA = [0] * N

maxA[N-1] = A[-1]
for i in range(1, N):
    maxA[N-i-1] = max(maxA[N-i], A[N-i])
# print(maxA)

max_diff = -10000000000
for i in range(N-1):
    max_diff = max(maxA[i] - A[i], max_diff)
# print(max_diff)
cnt = 0
for i in range(N-1):
    if maxA[i] - A[i] == max_diff:
        cnt += 1
print(cnt)


import sys
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    MAXl = [A[-1]]
    for i in range(1,N-1):
        MAXl.append(max(MAXl[i-1],A[-i-1]))
    MAXl.reverse()
    count = 0
    profit = 0
    for i in range(N-1):
        p = MAXl[i]-A[i]
        if p == profit:
            count += 1
        elif p > profit:
            profit = p
            count = 1

    print(count)

def __starting_point():
    main()
__starting_point()

N, T = map(int, input().split())
*A, = map(int, input().split())
max_price = A[N-1]
max_prof = 0
count = 1
for a in reversed(A[:N-1]):
    prof = max_price - a
    if prof < 0: max_price = a
    elif prof == max_prof: count += 1
    elif prof > max_prof: max_prof = prof; count = 1;
print(count)

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

diff = -1
mini = A[0]
cnt = 0
ans = 0

for i in range(1, N):
	now = A[i]

	if mini > now:
		mini = now
	else:
		if now - mini == diff:
			cnt += 1
		elif now - mini > diff:
			diff = now - mini
			ans = max(ans, cnt)
			cnt = 1
ans = max(ans, cnt)
print(ans)


N, M = map(int, input().split())
A = tuple(map(int, input().split()))
mini = 10**10
bnf = 0
cnt = 1
for i in range(N):
	mini = min(mini, A[i])
	_bnf = A[i] - mini
	if _bnf > bnf:
		bnf = _bnf
		cnt = 1
	elif _bnf == bnf:
		cnt += 1
print(cnt)

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

m = 10 ** 9
L = [m] * (N)


for i in range(0,N):
  if A[i] <= m:
    m = A[i]
  L[i] = A[i] - m

M = max(L)

print((L.count(M)))
  



#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
a,b = LS()
c = int(a+b)
for i in range(1,1000):
    if i * i == c:
        print("Yes")
        return
print("No")
"""

#B
"""
a,b = LI()
if a*b <= 0:
    print("Zero")
else:
    if b < 0:
        if (a-b) %2 == 1:
            print("Positive")
        else:
            print("Negative")
    else:
        print("Positive")
"""

#C
"""
n = II()
s = SR(n)
march = [[] for i in range(5)]
ch = list("MARCH")
for i in s:
    for j in range(5):
        if i[0] == ch[j]:
            march[j].append(i)
ans = 0
for i in range(5):
    for j in range(i):
        for k in range(j):
            if len(march[i])*len(march[j])*len(march[k]) == 0:
                break
            ans += len(march[i])*len(march[j])*len(march[k])
print(ans)
"""

#D
"""
n = II()
d = LIR(n)
q = II()
p = IIR(q)
d.insert(0,[0 for i in range(n+1)])
for i in range(n):
    d[i+1].insert(0,0)
for i in range(n):
    for j in range(n):
        d[i+1][j+1] += d[i+1][j]+d[i][j+1]-d[i][j]
ans = [0 for i in range(n**2+1)]

for a in range(n+1):
    for b in range(n+1):
        for c in range(a):
            for e in range(b):
                ans[(a-c)*(b-e)] = max(ans[(a-c)*(b-e)],d[a][b]-d[c][b]-d[a][e]+d[c][e])

for i in p:
    an = 0
    for a in range(i+1):
        an = max(an, ans[a])
    print(an)
"""
#E

"""
s = list(S())
ans = -1
s.insert(0,0)
d = 0
for i in range(1,len(s)):
    if s[i] != d:
        d = s[i]
        ans += 1
print(ans)
"""

#F
"""
n = II()
x,y = LI()
for _ in range(n-1):
    a,b = LI()
    if a == b:
        x = max(x,y)
        y = x
    else:
        i = max(x//a,y//b)
        while 1:
            if a*i >= x and b*i >= y:break
            i += 1
        x = a*i
        y = b*i
print(x+y)
"""
#G
"""
s = list(S())
p = 0
g = 0
for i in s:
    if i == "g":
        g += 1
    else:
        p += 1
ans = (g-p)//2
print(ans)
"""
#H
n,t = LI()
a = LI()
b = []
for i in range(n):
    b.append([i,a[i]])
b.sort(key = lambda x:x[1])
b = b[::-1]
m = []
if n == 1:
    print((1))
    return
i = 0
for j in range(n):
    while i < b[j][0]:
        m.append(b[j][1])
        i += 1
ans = 0
ma = 0
for i in range(n-1):
    ma = max(ma,m[i]-a[i])
for i in range(n-1):
    if m[i]-a[i] == ma:
        ans += 1
print(ans)
#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
min_A = 1000000001
max_diff = 0
ans = 0
for i in A:
    min_A = min(min_A, i)
    if i - min_A == max_diff:
        ans += 1
    if i - min_A > max_diff:
        max_diff = i - min_A
        ans = 1
print(ans)


#!/usr/bin/env python3

def main():
    n, t = list(map(int, input().split()))
    an = list(map(int, input().split()))

    mi = [an[0]]
    se_mi = {0}
    for i in range(1, n):
        if mi[i - 1] > an[i]:
            se_mi = {i}
        elif mi[i - 1] == an[i]:
            se_mi.add(i)
        mi.append(min(mi[i - 1], an[i]))

    ma = 0
    se_ma = set()
    for i in range(1, n):
        be = an[i] - mi[i - 1]
        if be > ma:
            ma = be
            se_ma = {i}
        elif be == ma:
            se_ma.add(i)
    print((len(se_ma)))

main()


N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
mxx, mnx = 0, 10**18
for a in A:
    if a-mnx > mxx:
        c, mxx = 1, a-mnx
    elif a-mnx == mxx:
        c += 1
    mnx = min(mnx, a)
print(c)


from collections import Counter

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

maxA = [0 for _ in range(N + 1)]
minA = [float('inf') for _ in range(N + 1)]

for i, a in enumerate(A):
    minA[i + 1] = min(minA[i], a)
for i, a in enumerate(reversed(A)):
    maxA[-1 - i] = max(maxA[-1 - (i - 1)], a)

maxProfit = 0
for i in range(1, N):
    if maxProfit < maxA[i + 1] - minA[i]:
        maxProfit = maxA[i + 1] - minA[i]

pairs = set([])
for i in range(1, N):
    if maxProfit == maxA[i + 1] - minA[i]:
        pairs.add((minA[i], maxA[i + 1]))

ans = len(pairs)
print(ans)

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
from typing import Union
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,t = inpl()
a = inpl()
m = []
mi = INF
for i in range(n-1):
    mi = min(mi, a[i])
    m.append(a[i+1]-mi)
print(m.count(max(m)))

N,T=map(int,input().split())
A=list(map(int,input().split()))
i=0
j=1
a=0
b=0
while i<=N-1:
    if j==N:
        i=N
    elif A[i]>A[j]:
        i=j
        j+=1
    else:
        if A[j]-A[i]>a:
            a=A[j]-A[i]
            b=1
            j+=1
        elif A[j]-A[i]==a:
            b+=1
            j+=1
        elif A[j]-A[i]<a:
            j+=1
print(b)

#! /usr/bin/env python3

N, T = map(int, input().split())
A = list(map(int, input().split()))
p = -1
dif = h = hc = lc = c = 0
for i in A[-2::-1]:
    a, b = A[p], A[p]-i
    if i > a:
        p = -c-2
    elif b >= dif:
        if a != h : h, hc = a, hc+1
        if b > dif : dif, lc = b, 0
        lc += 1
    c += 1
print(min(hc, lc))

n, t = map(int, input().split())
a = [int(i) for i in input().split()]
b = [0 for i in range(n)]
m = a[0]
for i in range(n):
    m = min(m, a[i])
    b[i] = a[i] - m
m = b[0]
k = 0
for i in range(n):
    if b[i] >= m:
        m = b[i]
        k = i
ans1 = 1
for i in range(n):
    if b[i] == m and i != k:
        ans1 += 1
b = [0 for i in range(n)]
m = a[n - 1]
for i in range(n - 1, -1, -1):
    m = max(m, a[i])
    b[i] = a[i] - m
m = b[n - 1]
k = 0
for i in range(n - 1, -1, -1):
    if b[i] <= m:
        m = b[i]
        k = i
ans2 = 1
for i in range(n):
    if b[i] == m and i != k:
        ans2 += 1
print(min(ans1, ans2))

n, t = map(int, input().split())
a = [int(x) for x in input().split()]
mx = [0] * n
mx[-1] = a[-1]
for i in range(n - 2, -1, -1):
  mx[i] = max(mx[i + 1], a[i])
d = 0
c = 0
for i in range(n - 1):
  cur = a[i]
  can = mx[i + 1]
  dd = can - cur
  if dd > d:
    d = dd
    c = 1
  elif dd == d:
    c += 1
print(c)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N,T = list(map(int,input().split()))
As = list(map(int,input().split()))

mns = [0] * N
mxs = [0] * N

mns[0] = As[0]
mxs[N-1] = As[N-1]

for i in range(1, N):
    j = N - i - 1
    mns[i] = min(As[i], mns[i-1])
    mxs[j] = max(As[j], mxs[j+1])

# print(mns)
# print(mxs)

mx_diff = -1
pairs = set()
for i in range(1, N):
    diff = mxs[i] - mns[i]
    if diff > mx_diff:
        mx_diff = diff
        pairs.clear()
    if diff >= mx_diff:
        pairs.add((mns[i], mxs[i]))
print((len(pairs)))
    




import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, t = li()
a = list(li())

mina = [0]*n
mina[0] = a[0]
maxprof = 0

for i in range(1, n):
    mina[i] = min(mina[i-1], a[i])

ans = 0
for i in range(n):
    if a[i] - mina[i] > maxprof:
        maxprof = a[i] - mina[i]
        ans = 1

    elif a[i] - mina[i] == maxprof:
        ans += 1

print(ans)

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

b = float('inf')

c = 0

ans = 0

for i in range(n):
    if a[i]<b:
        b = a[i]
    if a[i]-b == c:
        ans += 1
    elif a[i]-b > c:
        c = a[i]-b
        ans = 1

print(ans)


def main():

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

    if N == 1: return 0

    min_v = A[0]
    max_d = float('-inf')
    for i in range(1, N):
        if A[i] - min_v > max_d:
             max_d = A[i] - min_v
        if A[i] < min_v:
            min_v =  A[i]

    d = set()
    d.add(A[0])
    ans = 0
    for i in range(1, N):
        if A[i] - max_d in d: ans += 1
        d.add(A[i])
    return ans



def __starting_point():
    print((main()))

__starting_point()

n=int(input().split()[0])
s=input().split()
l=[0 for i in range(n)]
m=[0 for i in range(n)]
M=[0 for i in range(n)]
for i in range(n):
  l[i]=int(s[i])
m[0]=l[0]
M[0]=l[-1]
for i in range(1,n):
  m[i]=min(m[i-1],l[i])
  M[i]=max(M[i-1],l[-i-1])
M.reverse()
d=[M[i]-m[i] for i in range(n)]
ma=max(d)
memo=-1
cnt=0
for i in range(n):
   if d[i]==ma and m[i]!=memo:
      cnt+=1
      memo=m[i]
print(cnt)

#!/usr/bin/env python3

def main():
    n, t = list(map(int, input().split()))
    an = list(map(int, input().split()))

    mi = [an[0]]
    for i in range(1, n):
        mi.append(min(mi[i - 1], an[i]))

    ma = 0
    num_ma = 0
    for i in range(1, n):
        be = an[i] - mi[i - 1]
        if be > ma:
            ma = be
            num_ma = 1
        elif be == ma:
            num_ma += 1
    print(num_ma)

main()


n,t=list(map(int,input().split()))
a=list(map(int,input().split()))
pos={}
mx=[0]*(n+1)
for i in range(n-1,-1,-1):
    mx[i]=max(mx[i+1],a[i])
for i in range(n):
    pos[a[i]]=i
a.sort()
ans=0
b=0
for i in range(n):
    idx=pos[a[i]]
    if b<mx[idx]-a[i]:
        b=mx[idx]-a[i]
        ans=1
    elif b==mx[idx]-a[i]:
        ans+=1
print(ans)


n,t=map(int,input().split())
a=list(map(int,input().split()))
m=10**10
M=0
k=[]
for i in range(n):
	m=min(m,a[i])
	M=a[i]-m
	k.append(M)
o=max(k)
print(k.count(o))

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

h = []
B = [0]*N

for i in range(N):
    h.append(A[i])
    h = [min(h)]
    B[i] = h[0]

j = []
C = [0]*N

for i in range(N-1,-1,-1):
    j.append(A[i])
    j = [max(j)]
    C[i] = j[0]

B = B[:-1]
C = C[1:]
D = list([C[x]-B[x] for x in range(N-1)])
t = max(D)

s = 0
D.append(0)
for i in range(N-1):
    if D[i] == t and D[i] > D[i+1]:
        s += 1

print(s)


n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
m = a[-1]
tmp = 0
cnt = 0
for i in range(n - 2, -1, -1):
    p = m - a[i]
    if p > tmp:
        tmp = p
        cnt = 1
    elif p == tmp:
        cnt += 1
    m = max(m, a[i])
print(cnt)


n, t = map(int, input().split())
ax = list(map(int, input().split()))
# iより後ろの売る中で最も高いもののリスト
sell = []
for a in ax[::-1][:n-1]:
    if len(sell) == 0:
        sell.append([a,1])
        continue
    if a > sell[-1][0]:
        sell.append([a,1])
    elif a == sell[-1][0]:
        sell.append([a, sell[-1][1]+1])
    else:
        sell.append(sell[-1])
sell = sell[::-1]
ans = {}
for i in range(n-1):
    sell_p, cnt = sell[i]
    ans[sell_p-ax[i]] = ans.get(sell_p-ax[i],0)+1
print(ans[max(ans.keys())])

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

A_max_right = [A[-1]]
A_min_left = [A[0]]
for a in A[-2::-1]:
  A_max_right.append(max(a, A_max_right[-1]))
A_max_right.reverse()
for a in A[1:]:
  A_min_left.append(min(a, A_min_left[-1]))

A_dig = 0
for i in range(N):
  A_dig = max(A_dig, A_max_right[i] - A_min_left[i])
  
#print(A_max_right, A_min_left, A_dig)

def ct_edges(ma, mi, start):
    counting_max = 1 # 0:counting max, 1:counting min
    i = start
    ct_max = [0]
    ct_min = []
    while i >= 0 and A_max_right[i] == ma and A_min_left[i] == mi:
      if counting_max: 
        if A[i] == ma:
          ct_max[-1] += 1
        elif A[i] == mi:
          ct_min.append(1)
          counting_max = 0
      else: # counting min
        if A[i] == mi:
          ct_min[-1] += 1
        elif A[i] == ma:
          ct_max.append(1)
          counting_max = 1
      #print(i, A[i], ma, mi, ct_max, ct_min) 
      i -= 1
      
    if len(ct_max) != len(ct_min):
      print("Error! Type:1")
      return
      
    tmp_max = 0
    tmp_min = sum(ct_min)
    tmp = tmp_max + tmp_min
    for j in range(len(ct_max)):
      tmp_max += ct_max[j]
      tmp_min -= ct_min[j]
      tmp = min(tmp, tmp_max + tmp_min)
    
    ct = tmp
    end = i
    return ct, end

i = N-1  
ans = 0
while i >= 0:
  if A_max_right[i] - A_min_left[i] != A_dig:
    i -= 1
  else:
    #print(i)
    ct, i = ct_edges(A_max_right[i], A_min_left[i], start = i)
    ans += ct
print(ans)
    


import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N, T = map(int, input().split())
a = list(map(int, input().split()))
cm = [float("inf")] * (N + 1)
cmx = [0] * (N + 1)
for i in range(N):
  cm[i + 1] = min(cm[i], a[i])
  cmx[N - 1 - i] = max(cmx[N - i], a[N - 1 - i])
res = 0
x = 0
for i in range(N + 1):
  x = max(cmx[i] - cm[i], x)
for i in range(N):
  if cmx[i] - a[i] == x:
    res += 1
print(res)

ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys
n,t = ma()
A = lma()
INF=10**15

mns = [INF]*(n+1) ##mxs[i] :: max(A[i:n])
for i in range(n):
    mns[i] = min(mns[i-1],A[i])
c = 0
dmx = -1
for i in range(1,n):
    if A[i]-mns[i] >dmx:
        dmx=A[i]-mns[i]
        c=1
    elif A[i]-mns[i] ==dmx:
        c+=1
print(c)


# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N, T = inpl()
A = tuple(inpl())
m = A[0]
benefit = 0
pairs = 0
ans = 0

for i in range(1, N):
    a = A[i]
    d = a - m
    if d < 0:
        m = a
    elif d < benefit:
        continue
    elif d == benefit:
        pairs += 1
    elif d > benefit:
        ans = max(ans, pairs)
        benefit = d
        pairs = 1

ans = max(ans, pairs)
print(ans)

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

back = [(0,0)]*(N+1)
# (a,b): b is # of a
def heapsort(lst):
    h = []
    for value in lst:
        heappush(h,value)
    return [heappop(h) for i in range(len(h))]

for i in range(N, 0, -1):
    if A[i-1] > back[i][0]:
        back[i-1] = (A[i-1], 1)
    elif A[i-1] == back[i][0]:
        back[i-1] = (A[i-1], back[i][1] + 1)
    else:
        back[i-1] = back[i]

anslst = []
from heapq import heappush, heappop

for i in range(N):
    heappush(anslst, (- (back[i][0] - A[i]), back[i][1]) )
anslst = heapsort(anslst)


val = - anslst[0][0]

ans = 0
for i in range(N):
    if val != - anslst[i][0]:
        break
    ans += anslst[i][1] 
print(ans)



N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
minv = A[0]
maxv = -1
L = [0]
for i in range(1, N):
    if A[i] - minv > maxv:
        L = [i]
        maxv = A[i] - minv
    elif A[i] - minv == maxv:
        L.append(i)
    minv = min(minv, A[i])
print((len(L)))


N, T = map(int, input().split())
A = list(map(int, input().split()))
min_A = 1000000001
max_diff = 0
ans = 0
for i in A:
    min_A = min(min_A, i)
    if i - min_A == max_diff:
        ans += 1
    if i - min_A > max_diff:
        max_diff = i - min_A
        ans = 1
print(ans)

input()
a = [int(x) for x in input().split()]

lowest = a[0]
lowests = {a[0]}
diff = -1
pairs = []

for x in a[1:]:
    if lowest > x:
        lowests = {x}
        lowest = x
    elif lowest == x:
        lowests.add(x)
    elif diff == x - lowest:
        pairs += [(x, y) for y in lowests]
    elif diff < x - lowest:
        pairs = [(x, y) for y in lowests]
        diff = x - lowest

a, b = list(zip(*pairs))
print((min(len(set(a)), len(set(b)))))


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

low = [A[0]]
high = [A[N-1]]
for i in range(1, N):
    low.append(min(A[i], low[i-1]))
for i in reversed(list(range(N-1))):
    high.append(max(A[i], high[N-2-i]))

high.reverse()
max_gap = max([high[i] - low[i] for i in range(N)])
num = 0
first = True
for i in range(N):
    if high[i] - low[i] == max_gap:
        if first:
            idx = i
            num += 1
            first = False
        else:
            if low[idx] != low[i]:
                idx = i
                num += 1

print(num)


#!/usr/bin python3
# -*- coding: utf-8 -*-

import bisect

n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
mx = 0
p = [0] * n
for i in range(n-1,-1,-1):
    mx = max(mx, a[i])
    p[i] = mx - a[i]
p.sort()
print((n-bisect.bisect_left(p, p[-1])))


#a
"""
import math
a, b = map(str, input().split())
j = int(a + b)
if math.sqrt(j).is_integer():
    print("Yes")
else:
    print("No")
"""

#b
"""
ans = ["Positive","Negative"]
a, b = map(int, input().split())
if 0 < a:
    print("Positive")
elif b >= 0:
    print("Zero")
else:
    print(ans[(b-a)%2-1])
"""

#C
"""
import itertools
n = int(input())
MARCH = ["M", "A", "R", "C", "H"]
march = [0 for _ in range(5)]
for i in range(n):
    s = input()
    if s[0] in MARCH:
        march[MARCH.index(s[0])] += 1
num = list(range(5))
a = list(itertools.combinations(num, 3))
ans = 0
for i in a:
    bf = 1
    for k in i:
        bf *= march[k]
    ans += bf
print(ans)
"""

#D
"""
n = int(input())
D = [list(map(int, input().split())) for _ in range(n)]
q = int(input())
p = [int(input()) for _ in range(q)]
ans = [[0 for i in range(n)] for _ in range(n)]
for i in range(n):
    for j in range(n):
        break
for _ in p:
    print(ans[p])
"""

#E
"""
s = input()
bf = s[0]
ans = 0
for i in range(1,len(s)):
    if bf != s[i]:
        ans += 1
        bf = s[i]
print(ans)
"""

#F
"""
n = int(input())
ta = [list(map(int, input().split())) for _ in range(n)]
ans = ta[0]
for i in ta:
    if ans[0] <= i[0] and ans[1] <= i[1]:
        ans = i
    else:
        a = ((ans[0] - 1) // i[0]) + 1
        b = ((ans[1] - 1) // i[1]) + 1
        ab = max(a,b)
        ans = [i[0] * ab, i[1] * ab]
print(ans[0]+ans[1])
"""

#G
n, t = map(int, input().split())
a = list(map(int, input().split()))
minv = a[0]
maxv = 0
ans = 0
for i in range(1, n):
    if maxv == a[i] - minv:
        ans += 1
    elif maxv < a[i] - minv:
        maxv = a[i] - minv
        ans = 1
    else:
        minv = min(minv,a[i])
print(ans)

#H
"""
s = input()
ans = 0
for i in range(1,len(s)):
    if i % 2 == 1:
        if s[i] != "p":
            ans += 1
    else:
        if s[i] != "g":
            ans -= 1
print(ans)
"""

N,T=list(map(int,input().split()))
A=[int(i) for i in input().split()]
B=[0 for i in range(N)]
B[0]=A[0]
for i in range(1,N):
    B[i]=min([B[i-1],A[i]])
C=[A[i]-B[i] for i in range(N)]
M=max(C)
ans=0
for i in range(N):
    if C[i]==M:
        ans+=1
print(ans)


import numpy as np

input()
a = np.array(input().split(), dtype=np.int)

diff = a - np.minimum.accumulate(a)
print(((diff == diff.max()).sum()))



# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


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

diff = [0]*N

mini = A[0]
for i in range(1, N):
	now = A[i]
	if now <= mini:
		mini = now
	else:
		diff[i] = now - mini

sa = max(diff)

ans = 0
mini = A[0]
l = 1
r = 0
for i in range(1, N):
	now = A[i]
	if mini == now:
		l += 1
	elif now < mini:
		if r > 0:
			ans += min(l, r)
			r = 0
		mini = now
		l = 1
	else: # now > mini
		if now - mini == sa:
			r += 1

if r > 0:
	ans += min(l, r)
print(ans)


def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, t = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    b = collections.defaultdict(list)
    m_c = 10 ** 9
    for i, v in enumerate(a):
        if i != 0 and m_c < v:
            b[v-m_c] += [m_c]
        m_c = min(m_c, v)
    b = sorted(list(b.items()), reverse=True)[0]
    print((len(collections.Counter(b[1]))))


def __starting_point():
    slove()

__starting_point()

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

min_a = A[0]
profit = 0
ans = 0
for a in A[1:]:
    min_a = min(min_a, a)
    if a - min_a > profit:
        profit = a - min_a
        ans = 1
    elif a - min_a == profit:
        ans += 1
print(ans)

from collections import defaultdict
N,T=map(int,input().split())
A=[int(i) for i in input().split()]
mi=A[0]
s=0
dd=defaultdict(int)
for i in range(1,N):
    mi=min(mi,A[i])
    s=max(A[i]-mi,s)
    dd[A[i]-mi]+=1
print(dd[s])

from collections import Counter

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

T //= 2
profits = [0] * (N - 1)
minA = As[0]
for i, A in enumerate(As[1:]):
    profits[i] = T * (A - minA)
    minA = min(minA, A)

cnts = Counter(profits)
print((cnts[max(cnts.keys())]))


def main():
    N, T = [int(x) for x in input().split()]
    price = [int(x) for x in input().split()]

    minprice = 1000000000;
    maxbenefit = 0
    dict = {}
    res = 0

    for i in range(len(price)):
        if (price[i] < minprice): minprice = price[i]
        if (maxbenefit < (price[i] - minprice)): maxbenefit = (price[i] - minprice)
        dict[price[i]] = i

    for i in range(len(price)):
        if price[i] + maxbenefit in dict:
            if (dict[price[i] + maxbenefit] > i): res += 1

    print(res)

def __starting_point():
    main()

__starting_point()

n,t = list(map(int,input().split()))
a = list(map(int,input().split()))
mn = a[0]
l = []
for i in range(n-1):
    if a[i] < a[i+1]:
        l.append(a[i+1]-mn)        
    if a[i+1] < mn:
        mn = a[i+1]
if len(l) > 0:
    d = max(l)
ans = l.count(d)
print(ans)


def getlist():
	return list(map(int, input().split()))

#受け取り
N, T = getlist()
A = getlist()
m = A[0]
plus = -float("inf")
cost = 1
for i in range(1, N):
	if A[i] - m == plus:
		cost += 1
	elif A[i] - m > plus:
		plus = A[i] - m
		cost = 1
	else:
		pass
	m = min(m, A[i])

print(cost)

(N,T)=map(int,input().split())
a=list(map(int,input().split()))
x=10**9
d=0
counter=0
for i in a:
    if i<x:
        x=i
    elif i-x>d:
        d=i-x
        counter=1
    elif i-x==d:
        counter+=1
print(counter)

N, T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = [0 for k in range(N)]
B[0] = A[0]
for k in range(1,N):
    B[k] = min(B[k-1],A[k])
m = 0
for k in range(N):
    m = max(A[k]-B[k],m)
ans = 0
for k in range(N):
    if A[k]-B[k] == m:
        ans += 1
print(ans)


import numpy as np

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

A = np.array(list(map(int,input().split())))

B = np.minimum.accumulate(A)

C = A - B

ans = (C == C.max()).sum()

print(ans)


N, T = map(int, input().split())
a = [int(i) for i in input().split()]
b = [a[0]]
m = b[0]
for i in range(1,N):
	if m > a[i]:
		m = a[i]
	b.append(m)
c = [a[i] - b[i] for i in range(N)]
print(c.count(max(c)))

n,t=map(int,input().split())
A=[int(i) for i in input().split()]
A=A[::-1]
B,C=[0]*n,[0]*n
B[0]=A[0]
cur=A[0]
for i in range(1,n):
  cur=max(cur,A[i])
  B[i]+=cur
for i in range(n):
  C[i]=B[i]-A[i]
m=max(C)
ans=0
for i in range(n):
  if C[i]==m:
    ans+=1
print(ans)

from numpy import *
input()
a=array(input().split(),dtype=int)
d=a-minimum.accumulate(a)
print((d==d.max()).sum())

import numpy as np

N, T = np.array(input().split(), dtype="int")
A = np.array(input().split(), dtype="int")

max_num=A[-1]
num_dict = {}
for i in range(len(A)-1):
    ##print(A[-i-1],max_num - A[-i-2],num_dict)
    if(A[-i-1]>max_num):
        max_num=A[-i-1]
    if(max_num > A[-i-2]):
        if(max_num - A[-i-2] in num_dict):
            num_dict[max_num - A[-i-2]] +=1
        else:
            num_dict[max_num - A[-i-2]]=1
key = max(num_dict.keys())
print(num_dict[key])

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

# print(a)

minv = a[0]

value = [0] * n
for i, v in enumerate(a[1:], 1):
    if minv >= v:
        value[i] = 0
        minv = v
    else:
        value[i] = v - minv

maxv = max(value)
# print(maxv)
print((value.count(maxv)))


n,_,*a=map(int,open(0).read().split())
m=d=c=0
for t in a[::-1]:
    if t>m:
        m=t
    if m-t>d:
        d=m-t
        c=1
    elif m-t==d:
        c+=1
print(c)

#!/usr/bin/env pypy3

import collections


INF = 10 ** 10


def solve(n, t, xs):
    trades = collections.Counter()
    maxs = [INF for _ in range(n)]
    maxs[n - 1] = xs[n - 1]
    for i in range(n - 1)[::-1]:
        maxs[i] = max(xs[i], maxs[i + 1])
    for i in range(n):
        delta = maxs[i] - xs[i]
        if delta > 0:
            trades[delta] += 1
    max_delta = max(trades.keys())
    return trades[max_delta]


def main():
    n, t = list(map(int, input().split()))
    xs = list(map(int, input().split()))
    print((solve(n, t, xs)))


def __starting_point():
    main()

__starting_point()

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

p = a[n-1]
r = []

for i in range(n-1,-1,-1):
    if a[i] >= p:
        p = a[i]
    else:
        r.append(p-a[i])

res = r.count(max(r))

print(res)

n,t=list(map(int,input().split()))
ar=list(map(int,input().split()))
mn=float('inf')
mdif,mxc=-float('inf'),0
for e in ar:
    if(e-mn>mdif):
        mdif=e-mn
        mxc=1
    elif(e-mn==mdif):
        mxc+=1
    mn=min(mn,e)
print(mxc)


# ARC063D - 高橋君と見えざる手 / An Invisible Hand (ABC047D)
def main():
    N, T, *A = map(int, open(0).read().split())
    cur, cand = A[0], []
    for i in A:
        if i < cur:  # buy at the most inexpensive place
            cur = i
        else:
            cand += [i - cur]  # sell at higher places
    x = max(cand)  # the highest profits
    # count the number of pairs which produce x
    ans = sum(i == x for i in cand)
    print(ans)


def __starting_point():
    main()
__starting_point()

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

b=[0 for i in range(n)]
b[n-1]=a[n-1]
for i in range(n-1):
    b[n-i-2]=max(b[n-i-1],a[n-i-2])

samax=0
maxkai=0
for i in range(n-1):
    if b[i+1]-a[i]>samax:
        maxkai=1
        samax=b[i+1]-a[i]
    elif b[i+1]-a[i]==samax:
        maxkai+=1

print(maxkai)

#! /usr/bin/env python3

N, T = map(int, input().split())
A = list(map(int, input().split()))
pu = -1
SPU = set([])
SPD = []
b = 0
c = 0
for i in A[:-1][::-1]:
    if i > A[pu]:
        pu = -c-2
    elif i < A[pu] and A[pu]-i >= b:
        SPU.add(pu)
        b = A[pu]-i
        SPD += [b]
    c += 1

print(min(len(SPU), SPD.count(b)))

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    n,t = list(map(int,input().split()))
    a = list(map(int,input().split()))
    m = 0
    mc = inf
    r = 0
    for c in a:
        if mc > c:
            mc = c
            continue
        if c - mc > m:
            m = c - mc
            r = 1
            continue
        if c - mc == m:
            r += 1
    return r

print((f()))


N, T = map(int, input().split())
*A, = map(int, input().split())
min_price = A[0]
max_prof = 0
count = 1
for a in A[1:]:
    prof = a - min_price
    if prof < 0: min_price = a
    elif prof == max_prof: count += 1
    elif prof > max_prof: max_prof = prof; count = 1;
print(count)

N,T=map(int,input().split())
A=list(map(int,input().split()))
x=10**9
d=0
ans=0
for a in A:
    if a<x:
        x=a
    elif a-x>d:
        d=a-x
        ans=1
    elif a-x==d:
        ans+=1
print(ans)

def main():
    N, T = map(int, input().split())
    A = list(map(int, input().split()))
    tmp = A[-1]
    diff_A = [0] * N
    for i in range(N-1,-1,-1):
        tmp = max(A[i],tmp)
        diff_A[i] = tmp - A[i]

    print(diff_A.count(max(diff_A)))



def __starting_point():
    main()
__starting_point()

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,r,*a = list(map(int,read().split()))


high = a[-1]
delta = -1

for ai in a[::-1]:
    if high < ai:
        high = ai
    if high-ai > delta:
        delta = high-ai

#from collections import Counter
#d = Counter()

high = a[-1]

hs = 0
ls = 0

ans = 0
for ai in a[::-1]:
    if high < ai:
        high = ai
        hs = 1
        ans += min(hs,ls)
        ls = 0
    elif high == ai:
        hs += 1        
    
    if high - ai == delta:
        ls += 1
    

print((ans+min(hs,ls)))






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

B = [0]*N
C = [0]*N

h = A[0]
B[0] = h
for i in range(1,N):
    h = min(A[i],h)
    B[i] = h

h = A[-1]
C[-1] = h
for i in range(N-2,-1,-1):
    h = max(A[i],h)
    C[i] = h

B = B[:-1]
C = C[1:]
D = list([C[x]-B[x] for x in range(N-1)])
t = max(D)

s = 0
D.append(0)
for i in range(N-1):
    if D[i] == t and D[i] > D[i+1]:
        s += 1

print(s)


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

p = towns[-1]
r = []

for i in reversed(list(range(N))):
    if towns[i] >= p:
        p = towns[i]
    else:
        r.append(p-towns[i])

res = r.count(max(r))
print(res)


from collections import defaultdict

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

buy = a[0]
gain = defaultdict(int)
for ai in a:
    buy = min(buy, ai)
    gain[ai - buy] += 1
print((gain[max(gain)]))


import sys
from collections import Counter
readline = sys.stdin.readline

N, T = map(int, readline().split())
A = list(map(int, readline().split()))
Amax = [None]*N
Amax[N-1] = A[N-1]
for i in range(N-2, -1, -1):
    Amax[i] = max(Amax[i+1], A[i])

B = [am - a for a, am in zip(A, Amax)]
print(Counter(B)[max(B)])

N,T=map(int,input().split())
A=list(map(int,input().split())) # 0-indexed
B=[0 for i in range(N)] # B[i]~B[N-1]のmax
Bl=[set() for i in range(N)] # B[i]~B[N-1]のmaxとなるB[j]の添字jのリスト
B[N-1]=A[N-1]
Bl[N-1].add(N-1)
for i in range(N-2,-1,-1):
    if A[i]>B[i+1]:
        B[i]=A[i]
        Bl[i].add(i)
    elif A[i]==B[i+1]:
        B[i]=B[i+1]
        Bl[i]=Bl[i+1]+{i}
    elif A[i]<B[i+1]:
        B[i]=B[i+1]
        Bl[i]=Bl[i+1]

C=[B[i]-A[i] for i in range(N)]
'''
print(A)
print(B)
print(Bl)
print(C)
'''
Cm=max(C)
Cml=set()
for i in range(N):
    if C[i]==Cm:
        Cml.update(Bl[i])
'''
print(Cm)
print(Cml)
'''
ans=len(Cml)

print(ans)


def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    T = int(buflist[1])
    buf = input()
    buflist = buf.split()
    A = list(map(int, buflist))
    min_price = A[0]
    max_price_diff = 0
    max_diff_count = 0
    for i in range(1, N):
        if A[i] < min_price:
            min_price = A[i]
        elif A[i] - min_price > max_price_diff:
            max_price_diff = A[i] - min_price
            max_diff_count = 1
        elif A[i] - min_price == max_price_diff:
            max_diff_count += 1
    print(max_diff_count)

def __starting_point():
    main()

__starting_point()

#!/usr/bin/env python3

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

d = 0
ans = 1
l = A[0]
for a in A[1:]:
    l = min(l, a)
    r = a
    if r - l == d:
        ans += 1
    elif r - l > d:
        ans = 1
        d = r - l

print(ans)


from sys import setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(N, T) = reads()
A = reads()

B = [0] * N

B[0] = A[0]
for i in range(1, N):
  B[i] = min(B[i-1], A[i])

C = [max(A[i] - B[i], 0) for i in range(N)]

M = max(C)
result = sum(c == M for c in C)

print(result)


def inpl(): return [int(i) for i in input().split()]

N, T = inpl()
A = inpl()
minA = [0 for _ in range(N)]
minA[0] = A[0]
for i in range(N-1):
    minA[i+1] = min(minA[i], A[i+1]) 
ans = 1
maxpro = 0
for i in range(N-1):
    if A[i+1]-minA[i] == maxpro:
        ans += 1
    if A[i+1]-minA[i] > maxpro:
        ans = 1
        maxpro = A[i+1]-minA[i]

print(ans)

f = lambda: list(map(int,input().split()))
n,_ = f()
a = list(f())
b = [a[0]]+[0]*(n-1)
for i in range(1,n):
    b[i] = min(a[i], b[i-1])
c = [a[i]-b[i] for i in range(n)]
m = max(c)
print((c.count(m)))


# coding: utf-8

N, T = list(map(int, input().split()))
A = [int(s) for s in input().split()]

cm = A[0]
cd = 0
cnt = 0
for i in range(1, N):
    if A[i] < cm:
        cm = A[i]
    else:
        d = A[i] - cm
        if d == cd:
            cnt += 1
        elif d > cd:
            cd = d
            cnt = 1
print(cnt)


import sys
input = sys.stdin.readline

sys.setrecursionlimit(10000)


N, T = (int(i) for i in input().split())
A = [int(i) for i in input().split()]

ma = A[-1]
mas = 1
resma = 0
rescc = 0
for i in range(N-2, -1 ,-1):
    if A[i] > ma:
        ma = A[i]
        mas = 1
    elif A[i] == ma:
        mas += 1
    else:
        if ma - A[i] > resma:
            resma = ma - A[i]
            rescc = 1
        elif ma - A[i] == resma:
            rescc += 1
        else:
            pass

print(rescc)

_,_,*a=map(int,open(0).read().split());d={}
for x,y in zip(a,__import__("itertools").accumulate(a,min)):d[x-y]=d.get(x-y,0)+1
print(d[max(d.keys())])

N,T=list(map(int,input().split()))
a=list(map(int,input().split()))
max_profit=0
mini=a[0]
for i in range(1,N):
    max_profit=max(max_profit,a[i]-mini)
    mini=min(mini,a[i])
#print(max_profit)
mini=a[0]
ans=0
for i in range(1,N):
    if a[i]-mini==max_profit:
        ans+=1
    mini=min(mini,a[i])
print(ans)