using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, n, i,vreme=0,max,min;
            
            string[] ulaz = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(ulaz[0]);
            x = Convert.ToInt32(ulaz[1]);
            ulaz = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            
            for (i = 0; i < n; i++)
            {
               a[i]= Convert.ToInt32(ulaz[i]);
            }
            max = a[0];
            min = a[0];
            for (i = 0; i < n; i++)
            {
                if (max<a[i])
                {
                    max = a[i];
                }
                if (min>a[i])
                {
                    min = a[i];
                }
            }
            vreme = vreme + Math.Abs(max - x);
            vreme = vreme + Math.Abs(max - min);
            Console.WriteLine("{0}", vreme);
  
        }
    }
}