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

void sort( int a[], int n )
{
    for( int i = 0; i < n; i++ )
    {
        for( int j = i; j < n; j++ )
        {
            if ( a[i] > a[j] )
            {
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
}

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++;
        }
    }

    sort( posL, nL );
    sort( posR, nR );

    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("\n%d", vr );

    return 0;
}