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

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, x,min=999999,max=0,b;
            int[] a = new int[100];
            string[] s = Console.ReadLine().Split();
            n = int.Parse(s[0]);
            x = int.Parse(s[1]);
            string c = Console.ReadLine();
            var d = c.Split(' ');
            for (int i = 0; i < n; i++)
            {  
                a[i] = int.Parse(d[i]);
                if (a[i] < min)
                    min = a[i];
                else if (a[i] > max)
                    max = a[i];
            }
            if (x > min)
            {
                b = (x - min) + (max - min);
                Console.WriteLine(b);
            }
            else if (x < min) 
            {
                b = (min - x) + (max - min);
                Console.WriteLine(b);
            }

        }
    }
}