CodeEff/ECCO huggingface dataset:
# Original solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, T = MAP()
A = LIST()
B = [sorted(A[i+1:N])[-1]-A[i] for i in range(N-1)]
# print(B)
print((B.count(max(B))))

# Optimized solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, T = MAP()
A = LIST()
# B = [max(A[i+1:N])-A[i] for i in range(N-1)] # O(N^2)時間かかる
# print(B)
min_ = INF
B = []
for i in A:
	B.append(i-min_)
	# print(min_)
	if min_ > i:
		min_ = i
# print(B)
print((B.count(max(B))))
# Original solution
N,T = list(map(int,input().split()))
A = list(map(int,input().split()))

minA = A[0]
profit = 0
cnt = 0
for i in range(1,N):
    # A[i] で min(A[0..i-1])を売る場合の利益
    p = A[i]-minA
    if p==profit:
        cnt += 1 
    elif p>profit:
        profit = p
        cnt = 1
    # min(A[0..i]) の更新
    minA = min(minA,A[i])
    
print(cnt)


# Optimized solution
# python3 (3.4.3)
import sys
input = sys.stdin.readline

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

lowest = 10**9+1
profit = 0
ans = 0

for a in A:
    lowest = min(lowest, a)
    if a - lowest == profit:
        ans += 1
    elif a - lowest > profit:
        profit = a - lowest
        ans = 1

print(ans)
# Original solution
n, t = list(map(int, input().split()))
a = list([int(x) for x in input().split()])
#a = list(map(lambda x: int(x), in1.split()))
w_a = []
str_a = 0

for idx1 in range(len(a) - 1):
    w_a.append(a[idx1])
    if a[idx1 + 1] - min(w_a) > str_a:
        RC = 1
        str_a = a[idx1 + 1] - min(w_a)
    elif a[idx1 + 1] - min(w_a) == str_a:
        RC += 1

print(RC)


# Optimized solution
n, t = list(map(int, input().split()))
a = list([int(x) for x in input().split()])
#a = list(map(lambda x: int(x), in1.split()))
b = []
strlow = a[0]

for idx1 in range(1, len(a)):
    b.append(a[idx1] - strlow)
    if a[idx1] < strlow:
        strlow = a[idx1]

print((b.count(max(b))))
# Original solution
from collections import defaultdict

N, T = list(map(int, input().split()))
*a, = list(map(int, input().split()))
t = defaultdict(int)
m = a[0]
p = 0
ans = 0
for i in range(1, N):
    c = a[i] - m
    if t[m] < c:
        t[m] = c
    if a[i] < m:
        m = a[i]
    if c > p:
        p = c
        ans = 1
    elif c == p:
        ans += 1

print(ans)


# Optimized solution
N, T = list(map(int, input().split()))
*a, = list(map(int, input().split()))
m = a[0]
p = 0
ans = 0
for i in range(1, N):
    c = a[i] - m
    if a[i] < m:
        m = a[i]
    if c > p:
        p = c
        ans = 1
    elif c == p:
        ans += 1

print(ans)
# Original solution
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))

mx = [0] * (N + 1)
for i, a in enumerate(A[::-1], start=1):
    mx[-i] = max(mx[-i + 1], a)

mxD = 0
ans = 0
for i, a in enumerate(A):
    d = mx[i + 1] - a
    if mxD < d:
        mxD = d
        ans = 0
    if mxD == d:
        ans += 1

print(ans)


# Optimized solution
N, _ = list(map(int, input().split()))
A = list(map(int, input().split()))

mi = 10**18
mx = -10**18
ans = 0
for a in A:
    if mx < a - mi:
        ans = 0
        mx = a - mi
    if mx == a - mi:
        ans += 1
    mi = min(mi, a)

print(ans)
# Original solution
from collections import defaultdict
N,T=list(map(int,input().split(" ")))
A=list(map(int,input().split(" ")))
m=0
for i in range(1,N):
    a=min(A[:i])
    b=max(A[i:])
    if b-a>m:
        m=b-a
        sub=defaultdict(lambda:0)
        sub[str([a,b])]
    elif b-a==m:
        sub[str([a,b])]
c=list(sub.keys())
print((len(c)))

# Optimized solution
from collections import defaultdict
N,T=list(map(int,input().split(" ")))
A=list(map(int,input().split(" ")))
sub=defaultdict(lambda:0)
max1=A[0]
min1=A[0]
for i in range(N):
    if A[i]>=max1>=min1:
        max1=A[i]
        sub[max1-min1]+=1
    elif max1>=A[i]>=min1:
        max1=A[i]
        sub[max1-min1]+=1
    elif min1>=A[i]:
        min1=A[i]
        max1=A[i]
a=list(sub.keys())
b=max(a)
print((sub[b]))
# Original solution
from collections import defaultdict

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

c = defaultdict(int)
for i in range(N - 1):
    x = max(A[i + 1:])
    c[x - A[i]] += 1
print((c[max(c)]))


# Optimized solution
from collections import defaultdict

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

B = [0] * N
for i in range(N - 1):
    a = A[N - i - 1]
    B[i + 1] = max(B[i], a)
B = B[::-1]

c = defaultdict(int)
for i in range(N - 1):
    c[B[i] - A[i]] += 1
print((c[max(c)]))
# Original solution
from collections import defaultdict

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

B = [0] * N
for i in range(N - 1):
    a = A[N - i - 1]
    B[i + 1] = max(B[i], a)
B = B[::-1]

c = defaultdict(int)
for i in range(N - 1):
    c[B[i] - A[i]] += 1
print((c[max(c)]))


# Optimized solution
from itertools import accumulate
from collections import defaultdict

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

B = [x for x in accumulate(A[::-1], max)][::-1]
c = defaultdict(int)
for i in range(N - 1):
    c[B[i] - A[i]] += 1
print((c[max(c)]))
# Original solution
[n,t]=list(map(int,input().split()))
alist=list(map(int,input().split()))
salist=[alist[1]-alist[0]]
for i in range(1,n-1):
	saisho=min(alist[0:i])
	salist.append(alist[i+1]-saisho)
saidai=max(salist)
kaisu=salist.count(saidai)
print(kaisu)

# Optimized solution
[n,t]=list(map(int,input().split()))
alist=list(map(int,input().split()))
salist=[alist[1]-alist[0]]
saisho=min(alist[0],alist[1])
for i in range(1,n-1):
	saisho=min(saisho,alist[i])
	salist.append(alist[i+1]-saisho)
saidai=max(salist)
kaisu=salist.count(saidai)
print(kaisu)
# Original solution
N,T=list(map(int,input().split()))
A=tuple(map(int,input().split()))
B={}
for i in range(1,N):
  tmp=A[i]-min(A[:i])
  if tmp not in B:
    B[tmp]=1
  else:
    B[tmp]+=1
maxB=max(B)
print((B[maxB]))

# Optimized solution
N,T=list(map(int,input().split()))
A=tuple(map(int,input().split()))
x=[0]*N
x[0]=A[0]
for i in range(1,N):
  x[i]=min(x[i-1],A[i])
B={}
for i in range(1,N):
  tmp=A[i]-x[i-1]
  if tmp<0:
    continue
  if tmp not in B:
    B[tmp]=1
  else:
    B[tmp]+=1
d=list(B.items())
d.sort(reverse=True)
print((d[0][1]))
# Original solution
# -*- coding: utf-8 -*-
import sys 
from collections import deque
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, T = list(map(int, readline().split()))
A = list(map(int,readline().split()))
B = sorted(A,reverse = True)

d = defaultdict(int)
for i in range(N-1):
    a = A[i]
    p = B[0] - a
    d[p] += 1
    B.remove(a)
d = sorted(list(d.items()),reverse=True)
print((d[0][1]))

# Optimized solution
# -*- coding: utf-8 -*-
import sys 
from collections import deque
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

### セグメント木
# 0-index
# N: 処理する区間の長さ
N0 = 2**(N-1).bit_length()
data = [0]*(2*N0)

# 初期化
def init(A):
    for i in range(N):
        data[i+N0-1] = A[i]
    for i in range(N0-2,-1,-1):
        data[i] = max(data[2*i+1],data[2*i+2])

# a_k の値を x に更新
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = max(data[2*k+1], data[2*k+2])

# 区間[l, r)の最小値
def query(l, r):
    L = l + N0; R = r + N0
    s = 0
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, data[R-1])

        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

init(A)
d = defaultdict(int)
for i in range(N-1):
    a = A[i]
    high = query(i+1,N+1)
    p = high - a
    d[p] += 1
d = sorted(list(d.items()),reverse=True)
print((d[0][1]))
# Original solution
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))

vm = a[n - 1]#数列を右から見た時の最大値
d = dict()
for i in range(n - 2, -1, -1):
    if a[i] > vm:
        vm = a[i]
    else:
        df = vm - a[i]
        d[df] = d.get(df, 0) + 1

df_cnt = sorted(list(d.items()), key = lambda x:x[0], reverse = True)#差が大きい方から並べる

print((df_cnt[0][1]))

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

vm = a[n - 1]#数列を右から見た時の最大値
dfm = 0
cnt = 0
for i in range(n - 2, -1, -1):
    if a[i] > vm:
        vm = a[i]
    else:
        df = vm - a[i]
        if dfm < df:
            dfm = df
            cnt = 1
        elif dfm == df:
            cnt += 1

print(cnt)
# Original solution
def main():
    from heapq import heappush

    inf = 1 << 30

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

    h = [inf]
    ma = -1
    cnt = 0
    for x in A:
        d = x - h[0]
        if ma < d:
            ma = d
            cnt = 1
        elif ma == d:
            cnt += 1
        heappush(h, x)

    print(cnt)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    N, T = list(map(int, input().split()))
    *A, = list(map(int, input().split()))

    mi = A[0]
    d_ma = -1
    cnt = 0
    for x in A:
        d = x - mi
        if d_ma < d:
            d_ma = d
            cnt = 1
        elif d_ma == d:
            cnt += 1
        if mi > x:
            mi = x

    print(cnt)


if __name__ == '__main__':
    main()
# Original solution
# -*- coding: utf-8 -*-

"""
参考：https://atcoder.jp/contests/abc047/submissions/4077573
"""

import sys
import re
from collections import deque, Counter, defaultdict
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, product, combinations, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, T = MAP()
aN = LIST()

mx = -INF
l = aN[0]
cnt = 0
for i in range(1,N):
    # 最低値更新なら始点を動かす
    if aN[i] < l:
        l = aN[i]
    else:
        # 最高値更新ならその場所が操作対象になる
        if aN[i] - l > mx:
            mx = aN[i] - l
            cnt = 1
        # 同率最高値なら操作対象が1つ増える
        elif aN[i] - l == mx:
            cnt += 1
print(cnt)


# Optimized solution
# -*- coding: utf-8 -*-

"""
参考：https://atcoder.jp/contests/abc047/submissions/4077573
"""

import sys
def input(): return sys.stdin.readline().strip()
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, T = MAP()
aN = LIST()

mx = -INF
l = aN[0]
cnt = 0
for i in range(1,N):
    # 最低値更新なら始点を動かす
    if aN[i] < l:
        l = aN[i]
    else:
        # 最高値更新ならその場所が操作対象になる
        if aN[i] - l > mx:
            mx = aN[i] - l
            cnt = 1
        # 同率最高値なら操作対象が1つ増える
        elif aN[i] - l == mx:
            cnt += 1
print(cnt)
# Original solution
from collections import Counter

N, T, *A = list(map(int, open(0).read().split()))

mi = A[0]
ma = 0

B = Counter()
for a in A[1:]:
    b = a - mi
    B[b] += 1
    ma = max(ma, b)
    mi = min(mi, a)

print((B[ma]))


# Optimized solution
N, T, A0, *A = list(map(int, open(0).read().split()))

ma, mi = 0, A0
B = {}
for a in A:
    b = a - mi
    B[b] = B.get(b, 0) + 1
    ma, mi = max(ma, b), min(mi, a)

print((B[ma]))
# Original solution
from collections import deque,Counter
N,T=list(map(int, input().split()))
A=list(map(int, input().split()))

q=deque(A)
max_n=max(q)


b=[]
for i in range(N-1):
	q.popleft()
	if A[i]==max_n:
		max_n=max(q)

	b.append(max_n-A[i])

C=Counter(b)
max_key=max(C.keys())

print(C[max_key])

# Optimized solution
from collections import Counter
N,T=list(map(int, input().split()))
A=list(map(int, input().split()))

A_r=[None for i in range(N)]
n=0
for i in range(N-1,-1,-1):
	n=max(A[i],n)
	A_r[i]=n

B=[]
for i in range(N-1):
	B.append(A_r[i+1]-A[i])


C=Counter(B)

print(C[max(B)])
# Original solution
from collections import Counter

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


a_min = float("inf")
a_max = 0
a_diff = 0

counter = Counter([])

for a in A:
    hasModefied = False
    if a_min > a:
        a_min = a
        a_max = a
    if a_max < a:
        a_max = a
        hasModefied = True
        
    if hasModefied:        
        a_diff = a_max - a_min
        counter += {a_diff: 1}

keys = list(counter.keys())
max_key = max(keys)
print((counter[max_key]))

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


a_min = float("inf")
a_max = 0
a_diff = 0

ans = 0
a_diff = -1

for a in A:

    hasModefied = False
    if a_min > a:
        a_min = a
        a_max = a
    if a_max < a:
        a_max = a
        hasModefied = True
        
    if hasModefied:
        if a_diff == a_max-a_min:
            ans += 1
        elif a_diff < a_max-a_min:
            a_diff = a_max - a_min
            ans = 1
            
print(ans)
# Original solution
from collections import Counter
import sys
sdin = sys.stdin.readline

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

# iまででの最高と最低
diff_list = [] # iを含むiまでの最低
max_list = [] # iを含まないiからの最高

mini = max(a)
maxi = max(a)

# iまでの最低と最高を更新
for i in range(n-1):
    if a[i] < mini:
        mini = a[i]
    
    if a[i] == maxi:
        maxi = max(a[i+1:])
        
    diff_list.append(maxi-a[i])
    
cnt = Counter(diff_list)

# 最大値の個数
print((cnt[max(cnt.keys())]))
    

# Optimized solution
from collections import Counter
import sys
sdin = sys.stdin.readline

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

# iまででの最高と最低
diff_list = [] # iを含むiまでの最低
max_list = [] # iを含まないiからの最高

mini = max(a)
maxi = a[-1]
max_list = [a[-1]]
for i in range(n-1,0,-1):
    if a[i] > maxi:
        max_list.append(a[i])
        maxi = a[i]
    else:
        max_list.append(maxi)
        
max_list = max_list[::-1]

# iまでの最低と最高を更新
for i in range(n-1):
#    if a[i] < mini:
#        mini = a[i]
#    
#    if a[i] == maxi:
#        maxi = max(a[i+1:])
        
    diff_list.append(max_list[i]-a[i])
    
cnt = Counter(diff_list)

# 最大値の個数
print((cnt[max(cnt.keys())]))
# Original solution
n,t,*a=list(map(int,open(0).read().split()))
amin = [10**9+1] + [0]*n
amax = [0]*(n+1)
for i,x in enumerate(a):
	amin[i+1] = min(amin[i],x)
for i,x in enumerate(a[::-1]):
	amax[i+1] = max(amax[i],x)
d = max(i-j for i,j in zip(amax[-2::-1], amin[1:]))
dp = [[0]*(n+1) for _ in range(n+1)]
for i in range(n):
	for j in range(n):
		if a[i]-a[j]==d:
			dp[i+1][j+1] = dp[i][j] + 1
		else:
			dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
print((dp[-1][-1]))

# Optimized solution
from itertools import*;_,a=open(0);*a,=list(map(int,a.split()));c=[x-y for x,y in zip(a,accumulate(a,min))];print((c.count(max(c))))
# Original solution
_,_,*a=list(map(int,open(0).read().split()));c=[x-y for x,y in zip(a,__import__("itertools").accumulate(a,min))];print((c.count(max(c))))

# Optimized solution
def solve():
	_,_,*a=list(map(int,open(0).read().split()));c=[x-y for x,y in zip(a,__import__("itertools").accumulate(a,min))];print((c.count(max(c))))
if __name__=="__main__":solve()
# Original solution
# -*- coding: utf-8 -*-

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

l,r = 0,0
diff = 0
num = 0
lp = 0
for l in range(n):
    if(a[lp]<a[l]):
        pass
    else:
        for r in range(l+1,n):
            #print(l,r)
            if(a[r]-a[l]>diff):
                lp = l
                diff = a[r]-a[l]
                num = 1
            elif(a[r]-a[l]==diff):
                num += 1
print(num)
            
 


# Optimized solution
# -*- coding: utf-8 -*-
 
n,t = list(map(int, input().split()))
a = list(map(int, input().split())) 
 
m = 10**9+1
num = 0
diff = 0
for i in range(n):
    if(a[i]<m):
        m = a[i]
    if(a[i]-m > diff):
        diff = a[i]-m
        num = 1
    elif(a[i]-m == diff):
        num += 1
print(num)
# Original solution
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))

B = []

for i in range(1, N):
  B.append(A[i]-min(A[0:i]))
  
result = B.count(max(B))
print(result)

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

B = []
Amin = A[0]

for i in range(1, N):
  if A[i] < Amin:
    Amin = A[i]
  else:
    B.append(A[i] - Amin)

result = B.count(max(B))
print(result)
# Original solution
N,T = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

maxdiff = 0
ct = 0

for i in range(N):
    for j in range(i+1,N):
        if A[j]-A[i] > maxdiff:
            maxdiff = A[j]-A[i]
            ct = 1
        elif A[j]-A[i] == maxdiff:
            ct += 1

print(ct)

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

maxdiff = 0
ct = 0
mintmp = float("inf")
for A_i in A:
    mintmp = min(A_i,mintmp)
    diff = A_i - mintmp
    if diff > maxdiff:
        maxdiff = diff
        ct = 1
    elif diff == maxdiff:
        ct += 1
print(ct)
# Original solution
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())]))


# Optimized solution
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())]))
# Original solution
N,T=list(map(int,input().split()))
A=list(map(int,input().split()))

MAX=[A[-1]]

for i in range(N-2,-1,-1):
    MAX.append(max(MAX[-1],A[i]))

MAX=MAX[::-1]
SABUN=[MAX[i]-A[i] for i in range(N)]

#print(MAX)
#print(SABUN)
MAXSA=max(SABUN)

SEG=[]
for i in range(N):
    if SABUN[i]==MAXSA:
        SEG.append(i)

SE=[SEG[0]]
for i in range(1,len(SEG)):
    if A[SEG[i]]!=A[SEG[i-1]]:
        SE.append(SEG[i])
    
SE.append(N)
#print(SEG)
#print(SE)

ANS=0
for i in range(1,len(SE)):
    x=SE[i-1]
    y=SE[i]

    ANSS=float("inf")
    for l in range(x+1,y):

        count1=A[x:l].count(A[x])
        if count1==0:
            continue

        for j in range(l,y):
            if A[j]==A[x]:
                count2=A[j:y].count(A[x]+MAXSA)

                if ANSS>count1+count2:
                    ANSS=count1+count2
                break

        else:
            if A[x]+MAXSA in A[x:l]:
                continue
            else:
                count3=A[l:y].count(A[x]+MAXSA)

                if ANSS>min(count1,count3):
                    ANSS=min(count1,count3)

        #print(l,ANSS,count1,count2)

    #print(ANSS)

    ANS+=ANSS

print(ANS)

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

MAX=[A[-1]]

for i in range(N-2,-1,-1):
    MAX.append(max(MAX[-1],A[i]))

MAX=MAX[::-1]
SABUN=[MAX[i]-A[i] for i in range(N)]

#print(MAX)
#print(SABUN)
MAXSA=max(SABUN)

ANS=0
for i in range(N):
    if SABUN[i]==MAXSA:
        ANS+=1

print(ANS)
# Original solution
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ind = 0
rieki = []
if N == 2:
    print((1))
    exit()
sairi = 0
while True:
    ma = max(a[ind+1:N])
    kioku = ind+1
    ind = a.index(ma)
    if kioku != ind:
        mi = min(a[kioku:ind])
        if ma - mi > sairi:
            sairi = ma- mi
            ans = 1 
        elif ma - mi == sairi:
            ans += 1 
    if ind == N-1:
        break
print(ans)

# Optimized solution
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = []
mi = 10**9
for i in range(N):
    mi = min(mi,a[i])
    ans.append(a[i]-mi)
print((ans.count(max(ans))))