#include <bits/stdc++.h>
#define ll long long
#define INF (1LL << 60)
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) {cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl;}

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}
bool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 200005;

template<typename T> class segtree {
private:
    int n,sz,h;
    vector<T> node, lazy;
    void eval(int k) {
        if(lazy[k]){
            node[k] += lazy[k];
            if(k < n) {
                lazy[k*2] += lazy[k], lazy[k*2+1] += lazy[k];
            }
            lazy[k] = 0;
        }
    }

public:
    segtree(const vector<T>& v) : n(1), sz((int)v.size()), h(0) {
        while(n < sz) n *= 2, h++;
        node.resize(2*n, numeric_limits<T>::max());
        lazy.resize(2*n, 0);
        for(int i = 0; i < sz; i++) node[i+n] = v[i];
        for(int i = n-1; i >= 1; i--) node[i] = min(node[2*i], node[2*i+1]);
    }
    void range(int a, int b, T x, int k=1, int l=0, int r=-1){
        if(r < 0) r = n;
        eval(k);
        if(b <= l || r <= a){
            return;
        }
        if(a <= l && r <= b){
            lazy[k] += x;
            eval(k);
        }else{
            range(a, b, x, 2*k, l, (l+r)/2);
            range(a, b, x, 2*k+1, (l+r)/2, r);
            node[k] = min(node[2*k], node[2*k+1]);
        }
    }
    T query(int a, int b) {
        a += n, b += n - 1;
        for(int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
        b++;
        T res1 = numeric_limits<T>::max(), res2 = numeric_limits<T>::max();
        while(a < b) {
            if(a & 1) eval(a), res1 = min(res1, node[a++]);
            if(b & 1) eval(--b), res2 = min(res2, node[b]);
            a >>= 1, b >>= 1;
        }
        return min(res1, res2);
    }
    void print(){for(int i = 0; i < sz; i++) cout<<query(i,i+1)<< " ";cout<<endl;}
};

long long x[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q, a, b;
    cin >> n >> q >> a >> b;
    --a, --b;
    vl du(n, INF), dl(n, INF);
    rep(i,n){
        du[i] += i, dl[i] += n-i-1;
    }
    cin >> x[0];
    --x[0];
    ll prva = abs(a-x[0]), prvb = abs(b-x[0]);
    if(q == 0){
        cout << min(prva, prvb) << "\n";
        return 0;
    }
    du[a] -= INF - prvb, dl[a] -= INF - prvb;
    segtree<ll> sg0u(du), sg0l(dl);
    du[a] += INF - prvb, dl[a] += INF - prvb;
    du[b] -= INF - prva, dl[b] -= INF - prva;
    segtree<ll> sg1u(du), sg1l(dl);
    srep(i,1,q){
        // ashow(prva, prvb);
        cin >> x[i];
        --x[i];
        // a を動かす
        ll c = min(sg1u.query(x[i], n) - x[i], sg1l.query(0, x[i]) - (n-1-x[i]));
        sg1u.range(0, n, abs(x[i]-x[i-1])), sg1l.range(0, n, abs(x[i]-x[i-1]));
        // 前の b の位置で更新
        ll res1 = sg1u.query(x[i-1], x[i-1]+1) - x[i-1];
        if(res1 > c) sg1u.range(x[i-1], x[i-1]+1, c - res1);
        ll res2 = sg1l.query(x[i-1], x[i-1]+1) - (n-1-x[i-1]);
        if(res2 > c) sg1l.range(x[i-1], x[i-1]+1, c - res2);
        prva = min(prva + abs(x[i]-x[i-1]), c);
        // b を動かす
        ll d = min(sg0u.query(x[i], n) - x[i], sg0l.query(0, x[i]) - (n-1-x[i]));
        sg0u.range(0, n, abs(x[i]-x[i-1])), sg0l.range(0, n, abs(x[i]-x[i-1]));
        // 前の a の位置で更新
        res2 = sg0u.query(x[i-1], x[i-1]+1) - x[i-1];
        if(res2 > d) sg0u.range(x[i-1], x[i-1]+1, d - res2);
        res1 = sg0l.query(x[i-1], x[i-1]+1) - (n-1-x[i-1]);
        if(res1 > d) sg0l.range(x[i-1], x[i-1]+1, d - res1);
        // show(d);
        prvb = min(prvb + abs(x[i]-x[i-1]), d);
        if(i == q-1) cout << min(prva, prvb) << "\n";
    }
    return 0;
}


Measured memory_bytes: 39424