import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author User
 */
public class JednoDimenzionalniMilos {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        int x,n;
        int p,m;
        int r;
        Scanner in = new Scanner(System.in);
        n=in.nextInt();
        x=in.nextInt();
        int niz[]=new int[n];
        for (int i=0;i<n-1;i++){
            niz[i]=in.nextInt();
        }
        Arrays.sort(niz);
        
        if(niz[n-1]>=x){
            p=niz[n-1]-x;
        }
        else{
            p=x-niz[n-1];
        }
        
             if(niz[0]>=x){
            m=niz[0]-x;
        }
        else{
            m=x-niz[0];
        }
        
        r=2*Math.min(p,m)+Math.max(p,m)-x+1;
        
        System.out.println(r);
        
    }