#45752: 派森


chen971023@gmail.com (ZiaynGZiyaNG)


x, n = map(int, input().split())

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

 

a.append(x)

a.sort()

mouse = a.index(x)

a.remove(x)

if (n - mouse > mouse):

print(f"{n - mouse} {a[n - 1]}")

else:

print(f"{mouse} {a[0]}")