#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
//#include <utility>
//#include <complex>
#include <assert.h>
//#include <limits.h>
//#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <bits/stdc++.h>
using namespace std;

#define rank rankk
#define mp make_pair
#define pb push_back
#define eb push_back
//#define eb emplace_back
#define xo(a,b) ((b)&1?(a):0)
#define fi first
#define se second
#define tm tmp
//#define LL ll
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<int,ll>pil;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef long double ld;
const int INF=0x3f3f3f3f;
const ll INFF=4e11;
//const ll INFF=0x3f3f3f3f3f3f3f3fll;
const int MAX=2e6+5;
const ll MOD=998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline int powMM(int a,int b,int M){
    int ret=1;
    a%=M;
    while (b){
        if (b&1) ret=1LL*ret*a%M;
        b>>=1;
        a=1LL*a*a%M;
    }
    return ret;
}
namespace{
template<class T> inline int add(int x,T y){x+=y;if(x>=MOD)x-=MOD;return x;}
template<class T> inline void addi(int &x,T y){x+=y;if(x>=MOD)x-=MOD;}
template<class T> inline int mul(int x,T y){return 1LL*x*y%MOD;}
template<class T> inline void muli(int &x,T y){x=1LL*x*y%MOD;}
template<class T> inline int sub(int x,T y){int res=x-y;if(res<0)res+=MOD;return res;}
template<class T> inline void subi(int &x,T y){x-=y;if(x<0)x+=MOD;}
template<class T> inline int half(int x){return x&1?(x+MOD)>>1:x>>1;}
//ll mul(ll a , ll b,ll Q){
//    return (a * b - (ll) ((long double)a * b / Q) * Q) % Q;
//}
}
//#define debug
//clock_t t1 = clock();
//fprintf(stderr, "%ld ms\n", clock() - t1);

int n,q;
struct seg_tree{
    ll val[MAX],lazy[MAX];
    void init(){
        for(int i=0;i<MAX;i++)val[i]=INFF;
        //memset(val,0x3f,sizeof(val));
        memset(lazy,0,sizeof(lazy));
    }
    void pushup(int k){
        val[k]=min(val[k<<1],val[k<<1|1]);
    }
    void pushdown(int k){
        if(lazy[k]){
            val[k<<1]+=lazy[k];
            lazy[k<<1]+=lazy[k];
            val[k<<1|1]+=lazy[k];
            lazy[k<<1|1]+=lazy[k];
            lazy[k]=0;
        }
    }
    void update(int k,int lo,int l,int r,ll v){
        if(l==r){
            val[k]=min(val[k],v);
            return;
        }
        int mid=(l+r)/2;
        pushdown(k);
        if(lo<=mid)update(k<<1,lo,l,mid,v);
        else update(k<<1|1,lo,mid+1,r,v);
        pushup(k);
    }
    void addv(int k,int al,int ar,int l,int r,ll v){
        if(al<=l&&r<=ar){
            lazy[k]+=v;val[k]+=v;
            return;
        }
        pushdown(k);
        int mid=(l+r)/2;
        if(al<=mid)addv(k<<1,al,ar,l,mid,v);
        if(ar>mid)addv(k<<1|1,al,ar,mid+1,r,v);
        pushup(k);
    }
    ll query(int k,int ql,int qr,int l,int r){
        if(ql<=l&&r<=qr){
            return val[k];
        }
        pushdown(k);
        int mid=(l+r)/2;
        ll re=INFF;
        if(ql<=mid)re=min(re,query(k<<1,ql,qr,l,mid));
        if(qr>mid)re=min(re,query(k<<1|1,ql,qr,mid+1,r));
        return re;
    }
}sp,ss;
ll dp[MAX],x[MAX],a,b;
ll ans;
int main(){
    read(n);read(q);read(a);read(b);
    for(int i=1;i<=q;i++)read(x[i]);
    for(int i=1;i<=n;i++)dp[i]=INFF;
//    memset(dp,0x3f,sizeof(dp));
    dp[a]=min(dp[a],abs(x[1]-b));
    dp[b]=min(dp[b],abs(x[1]-a));
    sp.init();ss.init();
    sp.update(1,a,1,n,dp[a]+a);
    sp.update(1,b,1,n,dp[b]+b);
    ss.update(1,a,1,n,dp[a]-a);
    ss.update(1,b,1,n,dp[b]-b);

    for(int i=2;i<=q;i++){
        ll lo=x[i-1],lim=x[i];
        ll val1=ss.query(1,1,lim,1,n)+lim;
        ll val2=sp.query(1,lim,n,1,n)-lim;
//        printf("val1=%lld val2=%lld\n",val1,val2);
//        ss.val[1]+=abs(x[i]-x[i-1]);
//        sp.val[1]+=abs(x[i]-x[i-1]);
//        ss.lazy[1]+=abs(x[i]-x[i-1]);
//        sp.lazy[1]+=abs(x[i]-x[i-1]);
//        ss.addv(1,1,n,1,n,abs(x[i]-x[i-1]));
//        sp.addv(1,1,n,1,n,abs(x[i]-x[i-1]));
        ans+=abs(x[i]-x[i-1]);
        ss.update(1,x[i-1],1,n,min(val1,val2)-abs(x[i]-x[i-1])-x[i-1]);
        sp.update(1,x[i-1],1,n,min(val1,val2)-abs(x[i]-x[i-1])+x[i-1]);
        dp[lo]=min(dp[lo],min(val1,val2)-abs(x[i]-x[i-1]));

//        printf("%lld\n",min)
//        printf("dp[lo]=%lld\n",dp[lo]);
    }
//    printf("ans=%lld\n",ans);
    printf("%lld\n",ans+*min_element(dp+1,dp+1+n));
    return 0;
}
/*

10 6 9 6
4 6 3 5 7 4
*/


Measured memory_bytes: 68992