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

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)

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

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)

-# 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() -diff = [0] * N +diff = -1 +cnt = 0 +ans = 0 -    if now <= mini: +    if mini > now: -        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) +        if now - mini == diff: +            cnt += 1 +        elif now - mini > diff: +            diff = now - mini +            ans = max(ans, cnt) +            cnt = 1 +ans = max(ans, cnt)