#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;
const ll N = 2e5+9;
// const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod =998244353;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define pld pair<ld,ld>
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
ll lazy[4*N],a[N],t[4*N][3];
void push(ll v) {
    for(ll i = 0;i<3;i++){
        t[v*2][i] += lazy[v];
        t[v*2+1][i] += lazy[v];
    }
    lazy[v*2] += lazy[v];
    lazy[v*2+1] += lazy[v];
    lazy[v] = 0;

}
void build(ll v, ll tl, ll tr) {
    if (tl == tr) {
        t[v][0] = a[tl];
        t[v][1] = a[tl];
        t[v][2] = a[tl];
    } else {
        ll tm = (tl + tr) / 2;
        build(v*2, tl, tm);
        build( v*2+1, tm+1, tr);
        t[v][0] = min(t[2*v][0],t[2*v+1][0]);
        t[v][1] = min(t[2*v][1],t[2*v+1][1]);
        t[v][2] = min(t[2*v][2],t[2*v+1][2]);
    }
}
void update(ll v, ll tl, ll tr, ll l, ll r, ll addend) {
    if (l > r) 
        return;
    if (l == tl && tr == r) {
        t[v][0] += addend;
        t[v][1] += addend;
        t[v][2] += addend;
        lazy[v] += addend;
    } else {
        push(v);
        ll tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), addend);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, addend);
        t[v][0] = min(t[2*v][0],t[2*v+1][0]);
        t[v][1] = min(t[2*v][1],t[2*v+1][1]);
        t[v][2] = min(t[2*v][2],t[2*v+1][2]);
    }
}
void update1(ll v, ll tl, ll tr, ll pos, ll addend) {
    if (pos>tr || pos<tl) 
        return;
    if (tl==tr && tl==pos) {
        t[v][0] = addend;
        t[v][1] = addend-tl;
        t[v][2] = addend+tl;
        lazy[v] += addend;
    } else {
        push(v);
        ll tm = (tl + tr) / 2;
        update1(v*2, tl, tm, pos, addend);
        update1(v*2+1, tm+1, tr,pos, addend);
        t[v][0] = min(t[2*v][0],t[2*v+1][0]);
        t[v][1] = min(t[2*v][1],t[2*v+1][1]);
        t[v][2] = min(t[2*v][2],t[2*v+1][2]);
    }
}
ll query0(ll v, ll tl, ll tr, ll l, ll r) {
    if (l > r)
        return inf;
    if (l <= tl && tr <= r)
        return t[v][0];
    push(v);
    ll tm = (tl + tr) / 2;
    return min(query0(v*2, tl, tm, l, min(r, tm)), 
               query0(v*2+1, tm+1, tr, max(l, tm+1), r));
}

ll query1(ll v, ll tl, ll tr, ll l, ll r) {
    if (l > r)
        return inf;
    if (l <= tl && tr <= r)
        return t[v][1];
    push(v);
    ll tm = (tl + tr) / 2;
    return min(query1(v*2, tl, tm, l, min(r, tm)), 
               query1(v*2+1, tm+1, tr, max(l, tm+1), r));
}

ll query2(ll v, ll tl, ll tr, ll l, ll r) {
    if (l > r)
        return inf;
    if (l <= tl && tr <= r)
        return t[v][2];
    push(v);
    ll tm = (tl + tr) / 2;
    return min(query2(v*2, tl, tm, l, min(r, tm)), 
               query2(v*2+1, tm+1, tr, max(l, tm+1), r));
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
    ll q = 1;
    // cin>>t;
    while(q--){
        ll n,Q,A,B;cin>>n>>Q>>A>>B;
        memset(a,0x3f,sizeof(a));
        build(1,1,n);
        ll x;cin>>x;
        update1(1,1,n,A,abs(x-B));
        update1(1,1,n,B,abs(x-A));
        ll last = x;
        for(ll i = 1;i<Q;i++){
            cin>>x;
            ll t0 = query0(1,1,n,last,last)+abs(last-x);
            ll t1 = query1(1,1,n,1,x)+x;
            ll t2 = query2(1,1,n,x,n)-x;
            ll ans = min({t0,t1,t2});
            update(1,1,n,1,n,abs(x-last));
            update1(1,1,n,last,ans);
            last = x;
        }
        ll res = query0(1,1,n,1,n);
        cout<<res<<'\n';


    }
}

Measured memory_bytes: 21588