#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int n,x,i,max=0,min=1000000000;
    scanf("%d%d",&n,&x);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
    if(abs(n-max)>abs(n-min))
        i=abs(n-min)+abs(max-min)+1;
    else
        i=abs(n-max)+abs(max-min)+1;
    printf("%d",i);
}