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

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] s = Console.ReadLine().Split();
			int n = int.Parse(s[0]), x = int.Parse(s[1]);
			int[] niz = new int[n + 1];
			niz[n] = x;
			s = Console.ReadLine().Split();
			for (int i = 0; i < n; i++)
			{
				niz[i] = int.Parse(s[i]);
			}
			Array.Sort(niz);
			int d = 0,l = 0;
			for (int i = 0; i < n + 1; i++)
			{
				if (niz[i] == x)
				{
					d = i;
					break;
				}
			}
			if (Math.Abs(niz[d] - niz[0]) < Math.Abs(niz[n] - niz[d]))
			{
				l = 2 * (Math.Abs(niz[d] - niz[0])) + Math.Abs(niz[n] - niz[d]);
			}
			else
				l = 2 * (Math.Abs(niz[n] - niz[d])) + Math.Abs(niz[d] - niz[0]);
			Console.WriteLine(l);
		}
	}
}