x,n=map(int,input().split())
lo=input().split()
r,l,lm,rm=0,0,100000000,0
for i in range(n):
if int(lo[i])>x:
r=r+1
if int(lo[i])>rm:
rm=int(lo[i])
else:
l=l+1
if int(lo[i])<lm:
lm=int(lo[i])
if r>l:
print(r,rm)
else:
print(l,lm)