#include <iostream>
using namespace std;
#define endl "\n"


int main()
{
  int n, x, temp;
  cin >> n >> x;
  int a[n + 1];
  a[0] = x;
  for(int i = 1; i <= n; i++)
  {
    cin >> a[i];
    for(int j = 0; j < i; j++)
    {
      if(a[i] < a[j])
      {
        temp = a[j];
        a[j] = a[i];
        a[i] = temp;
      }
    }
  }
  if(x - a[0] > a[n] - x)
  {
    cout << 2 * a[n] - x - a[0] << endl;
  }
  else
  {
    cout << a[n] + x - 2 * a[0] << endl;
  }
}