a,b = map(int,input().split())c = list(map(int,input().split()))c.sort()big = [i for i in c if i>=a]smill = [j for j in c if j<a]if len(big)>len(smill):print(len(big),big[-1])else:print(len(smill),smill[0])