#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    long long unsigned int x,n,i,sum;
    cin>>n>>x;
    long long unsigned int a[n];
    for (i = 0; i<n; i++)
    {
        cin>>a[i];
        
    }
    sum = a[n-1]-a[0] +abs(int(x-a[0])) ;
    cout<<sum;
    
    
    return 0;
    
}