#include <bits/stdc++.h>
#define int long long
using namespace std;
int a[10000001];
signed main(){
int l,n;
cin>>l>>n;
if(n==0){cout<<"0 0"; return 0;}
for(int i=1;i<=n;i++) cin>>a[i];
int minn=-1145141919;
sort(a+1,a+n+1);
for(int i=1;i<=n;i++) minn=max(minn,min(a[i],l+1-a[i])); cout<<minn<<" ";
int x=a[1]+(a[n]-a[1])/2; cout<<max(l+1-x,x)+x-a[1];
return 0;
}