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

public class JednoDimenzionalniMilos {
  
    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;i++){
            niz[i]=in.nextInt();
        }
        Arrays.sort(niz);
                    
        if(niz[n-1]>x&&niz[0]<x){
        r=2*Math.abs(x-niz[0])+Math.abs(niz[n-1])-Math.abs(x);
        System.out.println(r);
        }
        else if(niz[n-1]<x){
        r=Math.abs(x)-Math.abs(niz[0]);
        System.out.println(r);
        }
        else if(niz[0]>x){
        r=Math.abs(niz[n-1])-Math.abs(x);
        System.out.println(r);
        }
        
    }
    
}