#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

int main()
{
	std::ios::sync_with_stdio(false);
    	int n,x,min = 100000000,max = -100000000,t;
        	std::cin >> n >> x;
            	for(int i = 0;i < n;++i)
                	{
                    		std::cin >> t;
                            		if(t > max)max = t;
                                    		if(t < min)min = t;
                                            		}
                                                    	t = abs(x - abs(min)) > abs(x - abs(max))?abs(x - abs(max)):abs(x - abs(min));
                                                        	t += max - min;
                                                            	std::cout << t;
                                                                }