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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int x = int.Parse(s[1]);
            int[,] A = new int[1, n];
            string[] s2 = Console.ReadLine().Split();
            int max = int.Parse(s2[0]);
            int min = int.Parse(s2[0]);
            for (int i = 1; i < n; i++)
            {
                A[0, i] = int.Parse(s2[i]);
                if (min > A[0, i])
                {
                    min = A[0, i];
                }
                if (max < A[0, i])
                {
                    max = A[0, i];
                }
            }
            int blize = Math.Abs(x - min);
            if (Math.Abs(x - max) < blize)
            {
                blize = Math.Abs(x - max);
            }
                Console.WriteLine(max - min + blize);
        }
    }
}