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

namespace kval31
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var data = line.Split(' ');
            long n = Convert.ToInt64(data[0]);
            long x = Convert.ToInt64(data[1]);

            line = Console.ReadLine();
            data = line.Split(' ');
            long[] komsije = new long[n];
            for (int i = 0; i < n; i++)
                komsije[i] = Convert.ToInt64(data[i]);

            Array.Sort(komsije);

            long k;
            if (Math.Abs(x - komsije[0]) < Math.Abs(x - komsije[n - 1]))
                k = Math.Abs(x - komsije[0]);
            else
                k = Math.Abs(x - komsije[n - 1]);
            for (int i = 1; i < n; i++)
            {
                k += komsije[i] - komsije[i - 1];
            }
            Console.WriteLine(k);
        }
    }
}