CodeEff/ECCO huggingface dataset:
# Original solution
def m():
    n = int(eval(input()))
    a = list(map(int, input().split()))

    def comb(x, y):
        c = 1
        p = 1
        for i in range(y, 0, -1):
            c = c * i
        for i in range(x, x - y, -1):
            p = p * i
        return p / c

    a.sort(reverse=True)
    tmp = 0
    ans = ""
    for i, v in enumerate(a):
        for k in range(i+1, n):
            m = comb(v, a[k])
            if tmp < m:
                tmp = m
                ans = "{0} {1}".format(v, a[k])

    return ans


print((m()))


# Optimized solution
def someone_ans():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    a.sort()
    x_max = a[n - 1]
    center = a[0]
    for i in range(1, n - 1):
        if abs(center - x_max / 2) > abs(a[i] - x_max / 2):
            center = a[i]
    return "{0} {1}".format(x_max, center)


print((someone_ans()))
# Original solution
import math
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()

def comb(n, r):
    return math.factorial(n) // math.factorial(n - r)

maxi = 0
i = n-1
key = a[i] // 2
ok = n
ng = -1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if key <= a[mid]: ok = mid
    else: ng = mid
if ok < i: 
    if comb(a[i], a[ok]) > maxi:
        maxi = comb(a[i], a[ok])
        ans = [a[i], a[ok]]
if ng >= 0: 
    if comb(a[i], a[ng]) > maxi:
        maxi = comb(a[i], a[ng])
        ans = [a[i], a[ng]]
print(("{} {}". format(ans[0], ans[1])))

# Optimized solution
import math
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()

def comb(n, r):
    return math.factorial(n) // math.factorial(n - r)

maxi = 0
i = -1
key = a[i] // 2
for j in range(n):
    if a[j] > key:
        break
# print(j, n-1)
# print(j, key, a)
if abs(a[j-1] - key) >= abs(a[j] - key) and j < n-1:
    ans = [a[i], a[j]]
else:
    ans = [a[i], a[j-1]]
# ok = n
# ng = -1
# while abs(ok - ng) > 1:
#     mid = (ok + ng) // 2
#     if key <= a[mid]: ok = mid
#     else: ng = mid
# if ok < i: 
#     if comb(a[i], a[ok]) > maxi:
#         maxi = comb(a[i], a[ok])
#         ans = [a[i], a[ok]]
# if ng >= 0: 
#     if comb(a[i], a[ng]) > maxi:
#         maxi = comb(a[i], a[ng])
#         ans = [a[i], a[ng]]
print(("{} {}". format(ans[0], ans[1])))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.sort()
mx=0
alarge=a[n-1]
if a[0]>=alarge/2:
  asmall=0
  comb=1
  for i in range(1,asmall+1): comb*=(alarge-i+1)/i
else:
  j=0
  while a[j]<alarge/2:
    j+=1
  if alarge<=a[j-1]+a[j]:
    asmall=a[j-1]
  else:
    asmall=a[j]
  comb=1
  for i in range(1,asmall+1): comb*=(alarge-i+1)/i
print(("{} {}".format(alarge,asmall)))


# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.sort()
alarge=a[n-1]
if a[0]>=alarge/2:
  asmall=a[0]
else:
  j=0
  while a[j]<alarge/2:
    j+=1
  if alarge<=a[j-1]+a[j]:
    asmall=a[j-1]
  else:
    asmall=a[j]
print(("{} {}".format(alarge,asmall)))
# Original solution
import math
n=eval(input())
a=list(map(int, input().split()))
a.sort()
a.reverse()

def comb(N,R):
	return math.factorial(N)/( math.factorial(N-R)*math.factorial(R) )

c=a[0]

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

min_b=min(b[1:])

d=[]
for i in range(1,n):
	if b[i]==min_b:
		d.append( (comb(c,a[i]),a[i]) )

print(c,sorted(d, key=lambda x:x[0],reverse=True)[0][1])


# Optimized solution
import math
n=eval(input())
a=list(map(int, input().split()))
a.sort()
a.reverse()


c=a[0]

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

min_b=min(b[1:])

d=[]
for i in range(1,n):
	if b[i]==min_b:
		d.append(a[i])

d.sort()
d.reverse()

print(c,d[0])
# Original solution
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

maxA = max(A)
fact = [1]
for i in range(1, maxA+10):
    fact.append(fact[-1] * i % MOD)
def rev(x):
    return pow(x, MOD-2, MOD)
def cmb(i, k):
    if(i < k): return 0
    return fact[i] * rev(fact[k]) * rev(fact[i-k]) % MOD

if N == 2:
    print(A[1], A[0])
    exit()

# print(' A', A)
maxA = max(A)
ind = bisect_left(A, maxA//2)
res = 0
ress = A[ind]
st = max(0, ind-2)
en = min(N, ind+2)
# print(' A[st], A[en]', A[st], A[en-1])
for i in range(st, en):
    # print('  i', i)
    val = cmb(maxA, A[i])
    if res<val:
        res = val
        ress = A[i]
print(maxA, ress)


# Optimized solution
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

fact = [1]
for i in range(1, N + 10):
    fact.append(fact[-1] * i % MOD)


def rev(x):
    return pow(x, MOD - 2, MOD)


def cmb(i, k):
    if i < k:
        return 0
    return fact[i] * rev(fact[k]) * rev(fact[i - k]) % MOD


A.sort()
if N == 2:
    print(A[1], A[0])
    exit()

mv = A[-1]
vm = mv // 2
bli = bisect_left(A, vm)
if bli == N - 1:
    print(mv, A[bli - 1])
elif bli == 0:
    print(mv, A[bli])
else:
    if vm - A[bli - 1] < A[bli] - vm:
        print(mv, A[bli - 1])
    else:
        print(mv, A[bli])
# Original solution
dp_t = dict()
dp_p = dict()


def main():
    n = int(eval(input()))
    a = [int(s) for s in input().split(" ")]
    a.sort(reverse=True)
    max_comb = (0, 0)
    max_num = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            c = comb(a[i], a[j])
            if max_num < c:
                max_num = c
                max_comb = (a[i], a[j])
    print(("%d %d" % max_comb))


def comb(n, r):
    t = 1
    if n in dp_t:
        t = dp_t[n]
    else:
        t = compute_kai(n)
    p = 1
    if (n, r) in dp_p:
        p = dp_p[(n, r)]
    else:
        pr = 1
        if r in dp_t:
            pr = dp_t[r]
        else:
            pr = compute_kai(r)
        if n - r in dp_t:
            p = dp_t[n - r]
        else:
            p = compute_kai(n -r)
        p *= pr
        dp_p[(n, r)] = p
    return t // p


def compute_kai(n):
    if n in dp_t:
        return dp_t[n]
    else:
        t = 1
        for i in range(n):
            t *= (n - i)
        dp_t[n] = t
        return t


if __name__ == '__main__':
    main()


# Optimized solution
dp_t = dict()
dp_p = dict()


def main():
    n = int(eval(input()))
    a = [int(s) for s in input().split(" ")]
    a.sort(reverse=True)
    t = a[0] // 2
    p = a[-1]
    if n == 2:
        print(("%d %d" % (a[0], a[1])))
        return
    i = 1
    while a[i] > t:
        i += 1
        if i >= n:
            i -= 1
            break
    if abs(a[i - 1] - t) > abs(a[i] - t):
        p = a[i]
    else:
        p = a[i - 1]
    print(("%d %d" % (a[0], p)))


def main1():
    n = int(eval(input()))
    a = [int(s) for s in input().split(" ")]
    a.sort(reverse=True)
    max_comb = (0, 0)
    max_num = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            c = comb(a[i], a[j])
            if max_num < c:
                max_num = c
                max_comb = (a[i], a[j])
    print(("%d %d" % max_comb))


def comb(n, r):
    t = 1
    if n in dp_t:
        t = dp_t[n]
    else:
        t = compute_kai(n)
    p = 1
    if (n, r) in dp_p:
        p = dp_p[(n, r)]
    else:
        pr = 1
        if r in dp_t:
            pr = dp_t[r]
        else:
            pr = compute_kai(r)
        if n - r in dp_t:
            p = dp_t[n - r]
        else:
            p = compute_kai(n -r)
        p *= pr
        dp_p[(n, r)] = p
    return t // p


def compute_kai(n):
    if n in dp_t:
        return dp_t[n]
    else:
        t = 1
        for i in range(n):
            t *= (n - i)
        dp_t[n] = t
        return t


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
M = A[-1]
a = M // 2
for i in range(N-1):
  if A[i] <= a and A[i+1] >= a:
    if (M-A[i])*A[i] >= (M-A[i+1])*A[i+1]:
      ans = [M, A[i]]
    else:
      ans = [M, A[i+1]]
ans = [str(b) for b in ans]
ans = ' '.join(ans)
print(ans)
      

# Optimized solution
n = int(input())
a = list(map(int, input().split()))
a.sort()
M = a[-1]
m = a[0]
C = -1
for i in range(n):
  c = a[i]*(M-a[i])
  if C < c:
    C = c
    m = a[i]
  else:
    break
print(M, m, sep=' ')
# Original solution
n=int(input())
A=list(map(int,input().split()))

X=sorted(A)

maxim=X[n-1]

if maxim%2==0:
    half=maxim//2
    target=half
    i=0
    while True:
        if (target+i in X)==1 and target+i != maxim:
            print(maxim,end=" ")
            print(target+i)
            break
        elif (target-i in X)==1 and target-i != maxim:
            print(maxim,end=" ")
            print(target-i)
            break
        else:
            i=i+1
#            print(i)

elif maxim%2==1:
    half=maxim//2
    target=half
    i=0
    while True:
        if (target+i+1 in X)==1 and target+i+1 != maxim:
            print(maxim,end=" ")
            print(target+i+1)
            break
        elif (target-i in X)==1 and target-i != maxim:
            print(maxim,end=" ")
            print(target-i)
            break
        else:
            i=i+1
#            print(i)


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

maximal=max(A)
print(maximal,end=" ")
B=list(map(lambda x:abs(x - maximal/2),A))
minimam=B.index(min(B))
if A[minimam]==maximal:
    print("0")
else:
    print(A[minimam])
# Original solution
from operator import mul
from functools import reduce

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(mul, list(range(n, n - r, -1)))
    denom = reduce(mul, list(range(1, r + 1)))
    return numer // denom


n = int(eval(input()))
a = list(map(int, input().split()))
ai = max(a)
ans_val = 0
for aj in set(a):
    if cmb(ai, aj) > ans_val:
        ans = [ai, aj]
        ans_val = cmb(ai, aj)
print((' '.join(map(str, ans))))


# Optimized solution
from operator import mul
from functools import reduce

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(mul, list(range(n, n - r, -1)))
    denom = reduce(mul, list(range(1, r + 1)))
    return numer // denom


n = int(eval(input()))
a = list(map(int, input().split()))
ai = max(a)
diff = float("inf")
for aj in set(a):
    if abs(ai / 2 - aj) < diff:
        ans = [ai, aj]
        diff = abs(ai / 2 - aj)
print((' '.join(map(str, ans))))
# Original solution
from operator import mul
from functools import reduce

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(mul, list(range(n, n - r, -1)))
    denom = reduce(mul, list(range(1, r + 1)))
    return numer // denom


n = int(eval(input()))
a = list(map(int, input().split()))
ai = max(a)
diff = float("inf")
for aj in set(a):
    if abs(ai / 2 - aj) < diff:
        ans = [ai, aj]
        diff = abs(ai / 2 - aj)
print((' '.join(map(str, ans))))


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
ai = max(a)
diff = float("inf")
for aj in set(a):
    if abs(ai / 2 - aj) < diff:
        ans = [ai, aj]
        diff = abs(ai / 2 - aj)
print((' '.join(map(str, ans))))
# Original solution
import math

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

max_num=max(a)
middle_num=math.ceil(max_num/2)
middle_num_up=middle_num
middle_num_down=middle_num

if n>2:
    for i in range(n):
        if middle_num_up in a:
            ans=middle_num_up
            break
        if middle_num_down in a:
            ans=middle_num_down
        else:
            middle_num_up+=1
            middle_num_down-=1
else:
    ans=min(a)

print(("{} {}".format(max_num,ans)))

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

max_num=max(a)
middle_num=max_num/2
num=0

for i in range(n):
    if a[i]> middle_num:
        num=i
        break

if middle_num-a[num-1]<=-middle_num+a[num]:
    print(("{} {}".format(max_num,a[num-1])))
else:
    print(("{} {}".format(max_num,a[num])))
# Original solution
from math import factorial as f


def nCr(n, r):
  return f(n) // (f(r) * f(n-r))


def main():
  n = int(eval(input()))
  a = list(map(int, input().split()))
  a.sort()
  
  max_comb = 0
  r = 0
  for i in range(n-1):
    tmp = nCr(a[-1], a[i])
    if tmp > max_comb:
      max_comb = tmp
      r = a[i]
  ans = "{} {}".format(a[-1], r)
  print(ans)

  
if __name__ == "__main__":
  main()


# Optimized solution
def main():
  n = int(eval(input()))
  a = list(map(int, input().split()))
  a.sort()
  
  r = 0
  c = a[-1] / 2
  for i in range(n-1):
    if abs(c-r) > abs(c-a[i]):
      r = a[i]
  ans = "{} {}".format(a[-1], r)
  print(ans)

  
if __name__ == "__main__":
  main()
# Original solution
from math import factorial
from bisect import bisect

def C(n, r):
	return factorial(n) // factorial(r) // factorial(n-r)

n=int(eval(input()))
a=sorted(map(int, input().split()))

z = a.pop()
r = bisect(a, z//2)
l = r - 1

if l < 0:
	print(("%d %d" % (z, a[r])))
elif r >= len(a):
	print(("%d %d" % (z, a[l])))
elif C(z, a[r]) > C(z, a[l]):
	print(("%d %d" % (z, a[r])))
else:
	print(("%d %d" % (z, a[l])))


# Optimized solution
n=int(eval(input()))
a=list(map(int, input().split()))
b=max(a)
_,c=min([(abs(b/2-x), x) for x in a])
print(("%d %d" % (b, c)))
# Original solution
def main():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    A.sort()
    m = A.pop()
    B = [[a, abs(a - (m / 2))] for a in A]
    B.sort(key = lambda x: x[1])
    print(('{} {}'. format(m, B[0][0])))

if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    A.sort()
    ans = [str((m := A.pop())), ]
    m /= 2
    A = [(a, abs(a - m)) for a in A]
    A.sort(key = lambda x: x[1])
    ans.append(str(A[0][0]))
    print((' '.join(ans)))

if __name__ == '__main__':
    main()
# Original solution
def d_binomial_coefficients():
    from bisect import bisect_left
    N = int(eval(input()))
    A = sorted([int(i) for i in input().split()])  # ソートしておく

    n = A[-1]  # comb(n, r) の n をこの値以外にする理由はない
    r = min(A[:-1], key=lambda x: abs(n / 2 - x))
    return '{0} {1}'.format(n, r)

print((d_binomial_coefficients()))

# Optimized solution
def d_binomial_coefficients():
    N = int(eval(input()))
    A = sorted([int(i) for i in input().split()])  # ソートしておく

    n = A[-1]  # n を大きく、r を n/2 に近づけると comb(n, r) は大きい
    r = min(A[:-1], key=lambda x: abs(n / 2 - x))
    return f'{n} {r}'

print((d_binomial_coefficients()))
# Original solution
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = 0
a_i = a[0]
a_j = a[1]
for idx in range(1, n):
    if ans < combinations_count(a_i, a[idx]):
        ans = combinations_count(a_i, a[idx])
        a_j = a[idx]

print(("%d %d" % (a_i, a_j)))


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)

max_a = max(a)
a.remove(max_a)
da = [abs(ai - max_a / 2) for ai in a]
med_i = da.index(min(da))

print(("%d %d" % (max_a, a[med_i])))
# Original solution
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result




n = int(eval(input()))
A = list(map(int, input().split()))
AS = sorted(list(set(A)))
n = AS[-1]
r = AS[0]
combM = cmb(n, r)

for i in range(1,len(AS)):
    tempr = AS[i]
    tempc = cmb(n, tempr)
    if combM >= tempc:
        break
    r = tempr
    combM = tempc


print((str(n) + ' ' + str(r)))



# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))
AS = sorted(list(set(A)))
n = AS[-1]
checkAS = len(AS)-1
nHalf = n/2
min = 10**10


for i in range(checkAS):
    temp = abs(AS[i]-nHalf)
    if min > temp:
        r = AS[i]
        min = temp

print((str(n) + ' ' + str(r)))
# Original solution
def isok(m):
    p0 = 0
    p1 = 1
    p2 = 1
    while p0 < N:
        # l0>=m ??¨???????????????p1????±???????
        if p1 <= p0: p1 = p0 + 1
        while d[p1] - d[p0] < m and p1 - p0 < N:
            p1 += 1
        if d[p1] - d[p0] < m:
            p0 += 1
            continue
        l0 = d[p1] - d[p0]
        # l1>=l0??¨???????????????p2????±???????
        if p2 <= p1: p2 = p1 + 1
        while d[p2] - d[p1] < m and p2 - p0 < N:
            p2 += 1
        if d[p2] - d[p1] < m:
            p0 += 1
            continue
        l1 = d[p2] - d[p1]
        if L - l0 - l1 >= l1:
            return True
        p0 += 1
    return False

N = int(eval(input()))
A = [0] * N
L = 0
for i in range(N):
    A[i] = int(eval(input()))
    L += A[i]
d = [0] * (2*N)
for i in range(1, 2*N):
    d[i] = d[i-1] + A[(i-1)%N]

left = 1
right = L // 3
ans = 0
while left <= right:
    m = (left + right) // 2
    if isok(m):
        ans = m
        left = m + 1
    else:
        right = m - 1
print(ans)

# Optimized solution
def d(p, q):
    return pos[p] - pos[q]

def solve():
    p0, p1, p2 = 0, 0, 0
    best = 0
    while p0 < N:
        # p1????±???????
        if p1 <= p0: p1 = p0 + 1
        while d(p1, p0) <= best and p1 - p0 < N:
            p1 += 1
        if d(p1, p0) <= best:
            p0 += 1
            continue
        # p2????±???????
        while d(p2, p1) > d(p1, p0) and p2 > p1:
            p2 -= 1
        if p2 <= p1: p2 = p1 + 1
        while d(p2,p1) < d(p1, p0) and p2 - p0 < N:
            p2 += 1
        if d(p2, p1) < d(p1, p0):
            p0 += 1
            continue
        # check
        if L - d(p2, p0) >= d(p1, p0):
            best = d(p1, p0)
            if best >= L//3:
                return best
        else:
            p0 += 1
    return best

N = int(eval(input()))
A = [0] * N
L = 0
for i in range(N):
    A[i] = int(eval(input()))
    L += A[i]
pos = [0] * (2*N)
for i in range(1, 2*N):
    pos[i] = pos[i-1] + A[(i-1)%N]

print((solve()))
# Original solution
# 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)


# Optimized solution
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)
# Original solution
N, T = list(map(int, input().split()))
a = [int(i) for i in input().split()]
d = [max(a[i:]) - a[i] for i in range(N-1)]
ans = d.count(max(d))
print(ans)

# Optimized solution
N, T = list(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))))
# Original solution
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)


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

max_profit = A_n[1] - A_n[0]
min_element = min(A_n[0], A_n[1])
for i in range(1, len(A_n)):
    if A_n[i] - min_element > max_profit:
        max_profit = A_n[i] - min_element
    if A_n[i] < min_element:
        min_element = A_n[i]

count = 0
for j in range(0, len(A_n)):
    if (A_n[j] + max_profit) in A_n[j:]:
        count += 1

print(count)


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

count = 0
max_profit = A_n[1] - A_n[0]
min_element = min(A_n[0], A_n[1])
for i in range(1, len(A_n)):
    if A_n[i] - min_element > max_profit:
        max_profit = A_n[i] - min_element
        count = 0

    if A_n[i] - min_element == max_profit:
        count += 1

    if A_n[i] < min_element:
        min_element = A_n[i]

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

max_income = 0
ans = 0
for i in range(N-1):
    buy = towns[i]
    sell = max(towns[i+1:])
    earn = sell-buy
    if max_income == earn:
        ans += 1
    elif max_income < earn:
        max_income = earn
        ans = 1

print(ans)


# Optimized solution
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)
# Original solution
#!/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()


# Optimized solution
#!/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()