#include <stdlib.h>
#include <stdio.h>

int sort( const void * a, const void * b )
{
    return( *(int*)a - *(int*)b );
}

int main()
{
    int n;
    int x;
    int vr = 0;

    scanf("%d %d", &n, &x );

    int posL[n];
    int posR[n];

    int nL = 0;
    int nR = 0;
    
    int cPos = x;

    for( int i = 0; i < n; i++ )
    {   
        int t;
        scanf("%d", &t);
        if ( t < x )
        {
            posL[ nL ] = t;
            nL++;
        } 
        if( t > x )
        {
            posR[ nR ] = t;
            nR++;
        }
    }

    qsort( posL, nL, sizeof(int), sort );
    qsort( posR, nR, sizeof(int), sort );

    for( int i = 0; i < nL; i++ )
    {
        vr = vr + abs( cPos - posL[i] );
        cPos = posL[ i ];
    }

    for( int i = 0; i < nR; i++ )
    {
        vr = vr + abs( cPos - posR[i] );
        cPos = posR[i];
    }

    printf("%d", vr );

    return 0;
}