def max_foods_and_last_position(x, n, foods):
foods.sort()
left_foods = []
right_foods = []
for food in foods:
if food < x:
left_foods.append(food)
else:
right_foods.append(food)
left_count = len(left_foods)
left_last_pos = left_foods[0] if left_foods else x
right_count = len(right_foods)
right_last_pos = right_foods[-1] if right_foods else x
if left_count >= right_count:
return left_count, left_last_pos
else:
return right_count, right_last_pos
x, n = map(int, input().split())
foods = list(map(int, input().split()))
max_count, last_position = max_foods_and_last_position(x, n, foods)
print(max_count, last_position)