#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
#include<random>
using namespace std ;

#define MAXN 200007

int n , q , st1 , st2 ; 
int a[ MAXN ] ;

long long inf ;

class Tree {
public :
    long long tr[ 5 * MAXN ] ;
    long long lazy[ 5 * MAXN ] ;
    long long mn_l[ 5 * MAXN ] ;
    long long mn_r[ 5 * MAXN ] ;

    void merge ( int where ) {
        tr[ where ] = min ( tr[ 2 * where ] , tr[ 2 * where + 1 ] ) ;
        mn_l[ where ] = min ( mn_l[ 2 * where ] , mn_l[ 2 * where + 1 ] ) ;
        mn_r[ where ] = min ( mn_r[ 2 * where ] , mn_r[ 2 * where + 1 ] ) ;
    }
    void push_lazy ( int where , int IL , int IR ) {
        tr[ where ] += lazy[ where ] ;
        mn_l[ where ] += lazy[ where ] ;
        mn_r[ where ] += lazy[ where ] ;

        if ( IL != IR ) {
            lazy[ 2 * where ] += lazy[ where ] ;
            lazy[ 2 * where + 1 ] += lazy[ where ] ;
        }
        lazy[ where ] = 0 ;
    }
    
    void init ( int where , int IL , int IR ) {
        tr[ where ] = inf ;
        lazy[ where ] = 0 ;
        if ( IL == IR ) {
            mn_l[ where ] = tr[ where ] - IL ;
            mn_r[ where ] = tr[ where ] + IL ;
            return ;
        }
        int mid = ( IL + IR ) / 2 ;
        init ( 2 * where , IL , mid ) ;
        init ( 2 * where + 1 , mid + 1 , IR ) ;
        merge ( where ) ;
    }
    void update_pt ( int where , int IL , int IR , int pos , long long val ) {
        push_lazy ( where , IL , IR ) ;
        if ( IR < pos || pos < IL ) { return ; }
        if ( IL == IR ) {
            if ( tr[ where ] > val ) {
                tr[ where ] = val ;
                mn_l[ where ] = val - IL ;
                mn_r[ where ] = val + IL ;
            }
            return ;
        }
        int mid = ( IL + IR ) / 2 ;
        update_pt ( 2 * where , IL , mid , pos , val ) ;
        update_pt ( 2 * where + 1 , mid + 1 , IR , pos , val ) ;
        merge ( where ) ;
    }
    void update_all ( long long val ) {
        lazy[ 1 ] += val ;
        push_lazy ( 1 , 1 , n ) ;
    }
    long long query ( int where , int IL , int IR , int CURL , int CURR , int type ) {
        push_lazy ( where , IL , IR ) ;
        if ( IR < CURL || CURR < IL ) { return inf ; }
        if ( CURL <= IL && IR <= CURR ) {
            if ( type == 1 ) { return mn_l[ where ] ; }
            else { return mn_r[ where ] ; }
        }
        int mid = ( IL + IR ) / 2 ;
        return min ( query ( 2 * where , IL , mid , CURL , CURR , type ) , query ( 2 * where + 1 , mid + 1 , IR , CURL , CURR , type ) ) ;
    }
};
Tree w ;

void input ( ) {
    scanf ( "%d%d%d%d" , &n , &q , &st1 , &st2 ) ;
    for ( int i = 1 ; i <= q ; ++ i ) {
        scanf ( "%d" , &a[ i ] ) ;
    }
}

void solve ( ) {
    inf = 1 ;
    for ( int i = 1 ; i <= 13 ; ++ i ) { inf *= 10 ; }
    w.init ( 1 , 1 , n ) ;
    w.update_pt ( 1 , 1 , n , st1 , abs ( st2 - a[ 1 ] ) ) ;
    w.update_pt ( 1 , 1 , n , st2 , abs ( st1 - a[ 1 ] ) ) ;
    for ( int i = 2 ; i <= q ; ++ i ) {
        long long aux1 = w.query ( 1 , 1 , n , 1 , a[ i ] , 1 ) + a[ i ] ;
        long long aux2 = w.query ( 1 , 1 , n , a[ i ] , n , 2 ) - a[ i ] ;
        w.update_all ( abs ( a[ i ] - a[ i - 1 ] ) ) ;
        w.update_pt ( 1 , 1 , n , a[ i - 1 ] , min ( aux1 , aux2 ) ) ;
    }
    w.push_lazy ( 1 , 1 , n ) ;
    printf ( "%lld\n" , w.tr[ 1 ] ) ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 25600