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

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
           
                string str = Console.ReadLine();
                string[] s = str.Split(' ');
            int n, x;
            n = int.Parse(s[0]);
            x = int.Parse(s[1]);
            string str1 = Console.ReadLine();
            string[] s1 = str1.Split(' ');
            int[] niz = new int[n];
            for (int i = 0; i < n; i++)
            {
                niz[i] = int.Parse(s1[i]);
                
            }
            Array.Sort(niz);
            int[] nizlevo = new int[n];
            int[] nizdesno = new int[n];
            int j = 0,k=0;
            for (int i = 0; i < n; i++)
            {
                if (niz[i] < x) { nizlevo[j] = niz[i]; j++; }
                else if (niz[i] > x) { nizdesno[k] = niz[i]; k++; }
            }
            int l = 0, d = 0;
            for (int i = n-1; i >=0; i--)
            {
                if (nizdesno[i] != 0) { d = nizdesno[i]; break; }
            }
            if (d == 0) d = x;

            for (int i = 0; i <n; i++)
            {
                if (nizlevo[i] != 0) { l = nizlevo[i]; break; }
            }
            if (l == 0) l = x;
            if ((x - l) <= (d - x)) Console.WriteLine(2*(x-l)+(d-x));
            else Console.WriteLine((x - l)  +2*(d - x));
        }
    }
}