#include<stdio.h>
void _min(int*,int*,int,int,int);
void _max(int*,int*,int,int,int);
void BubbleSort(int *arr, int size)
{
int i, j, tmp;
for (i = 0; i < size - 1; i++) {
for (j = 0; j < size - i - 1; j++) {
if (arr[j] > arr[j+1]) {
tmp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = tmp;
}
}
}
}
int main(){
int the_longgest;
int _long,sol,n;
scanf("%d",&_long);
scanf("%d",&sol);
int pos[sol];
for(n=0;n<sol;n++){
scanf("%d",&pos[n]);
}
if(_long%2==0){
the_longgest=_long/2;
}
else{
the_longgest=(_long-1)/2+1;
}
int left[sol],right[sol],v,l,r;
for(n=0;n<sol;n++){
v = pos[n]-the_longgest;
if(v>0){
right[++r]=v;
}else{
left[++l]=-v;
}
}
BubbleSort((int*)left,l);
BubbleSort((int*)right,r);
_min((int*)left,(int*)right,l,r,the_longgest);
_max((int*)left,(int*)right,l,r,the_longgest);
return 0;
}
void _min(int *left,int*right,int l,int r,int the_loggest){
printf("%d\n",*left<*right?the_loggest-*left:the_loggest-*right);
return;
}
void _max(int *left,int*right,int l,int r,int the_loggest){
int w,v,hl,hr;
while(1){
v = abs(*left-*right);
if(v==1||v==0){
printf("%d\n",*left<*right?the_loggest+*left+w:the_loggest+*right+w);
return;
}
if(*left>0&&!hl){
*left--;
}else{
hl=1;
*left++;
}
if(*right>0&&!hr){
*right--;
}else{
hr=1;
*right++;
}
w++;
}
}