include "bits/stdc++.h"
using namespace std;
int main(){
int x,n;
while(cin>>x>>n){
int ptr[n];
for(int i=0;i<n;i++)
cin>>ptr[i];
sort(ptr,ptr+n);
int low=0,high=0;
for(int i=0;i<n;i++){
if(ptr[i]<x)
low++;
else
high++;
}
if(low>high){
cout<<low<<" "<<ptr[0];
}
else
cout<<high<<" "<<ptr[n-1];
}
}