import java.util.*;
import java.util.Arrays;

public class Zadatak1 {

    public static void main(String[] args) {

        Scanner a = new Scanner(System.in);
     int i,n=a.nextInt(),x=a.nextInt(),sec;
     int[] h = new int[n];
     for(i=0;i<=n;i++){
         if((a.hasNextInt()))
         h[i]=a.nextInt();
     }
       Arrays.sort(h);
     int min=h[0];
     int max=h[h.length-1];
     if(x<min) sec=max-x;
     else if(x>max) sec=x-min;
     else{
         sec=x+max+2*min;
     }
     System.out.println(sec);


    }
}