#include<bits/stdc++.h>
using namespace std;
const int size = 5005;
int a[size];
int main(){
int L,N;
cin>>L>>N;
if(!N){
cout<<"0 0"<<endl;
return 0;
}for(int i=1;i<=N;i++) cin>>a[i];
sort(a+1,a+N+1);
int max_time,min_time;
for (int i=1;i<=N;i++)
min_time=max(min(a[i],L+1-a[i]),min_time);
max_time=max(L+1-a[1],a[N]);
cout<<min_time<<' '<<max_time<<endl;
return 0;
}
本蒟蒻调了好久还是10分,望大佬救助