int main() {
int mouse_pos, n;
scanf("%d %d", &mouse_pos, &n);
int food_pos[1005];
int left[1005], right[1005];
int left_count = 0, right_count = 0;
for (int i = 0; i < n; i++) {
scanf("%d", &food_pos[i]);
if (food_pos[i] < mouse_pos) {
left[left_count++] = food_pos[i];
} else if (food_pos[i] > mouse_pos) {
right[right_count++] = food_pos[i];
}
}
int max_eat = left_count;
int last_pos = -1;
if (left_count > 0) {
last_pos = left[0];
for (int i = 1; i < left_count; i++) {
if (left[i] < last_pos)
last_pos = left[i];
}
}
if (right_count > max_eat) {
max_eat = right_count;
if (right_count > 0) {
last_pos = right[0];
for (int i = 1; i < right_count; i++) {
if (right[i] > last_pos)
last_pos = right[i];
}
}
}
printf("%d %d\n", max_eat, last_pos);
return 0;
}