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: HARD

Solutions:
(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()))
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)


(N, T) = 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])
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
(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])

def ct_edges(ma, mi, start):
	counting_max = 1
	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
		elif A[i] == mi:
			ct_min[-1] += 1
		elif A[i] == ma:
			ct_max.append(1)
			counting_max = 1
		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:
		(ct, i) = ct_edges(A_max_right[i], A_min_left[i], start=i)
		ans += ct
print(ans)


(_, _, *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())])


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) = zip(*pairs)
print(min(len(set(a)), len(set(b))))


(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)


def main():
	(n, t) = 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()


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()


import heapq
(N, T) = 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(map(lambda x: C[x] - B[x], 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) = 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)


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()


import sys
read = sys.stdin.read
readline = sys.stdin.readline
(n, r, *a) = 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
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()))
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)


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
	elif ma - A[i] > resma:
		resma = ma - A[i]
		rescc = 1
	elif ma - A[i] == resma:
		rescc += 1
	else:
		pass
print(rescc)


from sys import exit, 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)


(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
	elif now - mini == sa:
		r += 1
if r > 0:
	ans += min(l, r)
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)))
main()


(N, T) = map(int, input().split())
A = 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)


import bisect
(n, t) = 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]))


(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])
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)


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()


import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

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

def TUPLE():
	return tuple(map(int, input().split()))

def ZIP(n):
	return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
(N, T) = MAP()
A = LIST()
buy = [0] * N
sell = [0] * N
buy_memo = [0] * N
sell_memo = [0] * N
tmp_buy = INF
tmp_buy_memo = -1
for i in range(N):
	if A[i] <= tmp_buy:
		tmp_buy = A[i]
		tmp_buy_memo = i
	buy[i] = tmp_buy
	buy_memo[i] = tmp_buy_memo
tmp_sell = 0
tmp_sell_memo = -1
for i in range(N - 1, -1, -1):
	if tmp_sell <= A[i]:
		tmp_sell = A[i]
		tmp_sell_memo = i
	sell[i] = tmp_sell
	sell_memo[i] = tmp_sell_memo
diff = [sell[i] - buy[i] for i in range(N)]
max_diff = max(diff)
buy_possible = [0] * N
sell_possible = [0] * N
for i in range(N):
	if diff[i] == max_diff:
		buy_possible[buy_memo[i]] = 1
		sell_possible[sell_memo[i]] = 1
print(min(sum(buy_possible), sum(sell_possible)))


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)
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)


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,) = 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)


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()


from collections import defaultdict
(n, t) = 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)])


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()


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) = 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)


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)


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()


(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)


(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()))
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)


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)


(n, t) = 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)


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
(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)
	quit()
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)


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
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(value.count(maxv))


(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)


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 = 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)


(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) = 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)


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)


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))


(N, T) = 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))


import sys
input = sys.stdin.readline
from collections import *
(N, T) = map(int, input().split())
A = list(map(int, input().split()))
min_acc = [A[0]]
for i in range(1, N):
	min_acc.append(min(min_acc[-1], A[i]))
M = 0
for i in range(1, N):
	M = max(M, A[i] - min_acc[i - 1])
ans = 0
for i in range(1, N):
	if A[i] - min_acc[i - 1] == M:
		ans += 1
print(ans)


(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)


(N, T) = list(map(int, input().split()))
A = list(map(int, input().split()))
back = [(0, 0)] * (N + 1)

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) = map(int, input().split())
alist = list(map(int, input().split()))
minal = [alist[0]]
maxal = [alist[-1]]
for a in alist[1:]:
	if minal[-1] > a:
		minal.append(a)
	else:
		minal.append(minal[-1])
for a in alist[::-1][1:]:
	if maxal[-1] < a:
		maxal.append(a)
	else:
		maxal.append(maxal[-1])
maxal = maxal[::-1]
maxda = 0
ans = 0
(prevmina, prevmaxa) = (None, None)
for (mina, maxa) in zip(minal, maxal):
	if prevmina == mina and prevmaxa == maxa:
		continue
	elif maxa - mina == maxda:
		ans += 1
	elif maxa - mina > maxda:
		maxda = maxa - mina
		ans = 1
	(prevmina, prevmaxa) = (mina, maxa)
print(ans)


(N, T) = 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
	elif now - mini == diff:
		cnt += 1
	elif now - mini > diff:
		diff = now - mini
		ans = max(ans, cnt)
		cnt = 1
ans = max(ans, cnt)
print(ans)


from __future__ import division, print_function, absolute_import, unicode_literals
(N, T) = 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])
max_diff = -10000000000
for i in range(N - 1):
	max_diff = max(maxA[i] - A[i], max_diff)
cnt = 0
for i in range(N - 1):
	if maxA[i] - A[i] == max_diff:
		cnt += 1
print(cnt)


def main():
	(N, T, *A) = map(int, open(0).read().split())
	(cur, cand) = (A[0], [])
	for i in A:
		if i < cur:
			cur = i
		else:
			cand += [i - cur]
	x = max(cand)
	ans = sum((i == x for i in cand))
	print(ans)

def __starting_point():
	main()
__starting_point()


(N, T) = 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)


(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)))


(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
	elif 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)


(n, t) = map(int, input().split())
ax = list(map(int, input().split()))
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())])


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)))


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))


(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)


(N, T) = 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(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
		elif low[idx] != low[i]:
			idx = i
			num += 1
print(num)


import sys

def solve(N: int, T: int, A: 'List[int]'):
	right_max = [0] * N
	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

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	N = int(next(tokens))
	T = int(next(tokens))
	A = [int(next(tokens)) for _ in range(N)]
	solve(N, T, A)
main()


(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)


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) = 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)


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) = 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)


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(b.items(), reverse=True)[0]
	print(len(collections.Counter(b[1])))
slove()


(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, 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)