#include <iostream>
#include <bits/stdc++.h>

using namespace std;
const long long MAXN = 2e5+5;
long long q[MAXN];
struct segtree{
    long long seg[5*MAXN];
    long long lazy[5*MAXN];
    void push(long long curr){
        if(lazy[curr]){
            seg[2*curr]+=lazy[curr];
            seg[2*curr+1]+=lazy[curr];
            lazy[2*curr] += lazy[curr];
            lazy[2*curr+1]+=lazy[curr];
            lazy[curr] = 0;
        }
    }
    void build(long long curr,long long l,long long r){
        if(l==r){
            seg[curr] = 1e18;
            lazy[curr] = 0;
            return;
        }
        long long mid = (l+r)/2;
        build(2*curr,l,mid);
        build(2*curr+1,mid+1,r);
        seg[curr] = min(seg[2*curr],seg[2*curr+1]);
    }
    void insert(long long curr,long long l,long long r,long long ind,long long val){
        if(l==r){
            seg[curr] = min(seg[curr],val);
            return;
        } 
        if(l!=r){
            push(curr);
        }
        long long mid = (l+r)/2;
        if(ind<=mid){
            insert(2*curr,l,mid,ind,val);
        }else{
            insert(2*curr+1,mid+1,r,ind,val);
        }
        seg[curr] = min(seg[2*curr],seg[2*curr+1]);
    }
    void update(long long curr,long long l,long long r,long long tl,long long tr,long long val){
        if(l>tr||r<tl){
            return;
        }
        if(l!=r){
            push(curr);
        }
        if(l>=tl && r<=tr){
            seg[curr] += val;
            lazy[curr]+=val;
            return;
        }
        long long mid = (l+r)/2;
        update(2*curr,l,mid,tl,tr,val);
        update(2*curr+1,mid+1,r,tl,tr,val);
        seg[curr] = min(seg[2*curr],seg[2*curr+1]);
    }
    long long query(long long curr,long long l,long long r,long long tl,long long tr){
        if(l>tr||r<tl){
            return 1e18;
        }
        if(l!=r){
            push(curr);
        }
        if(l>=tl && r<=tr){
            return seg[curr];
        }
        long long mid = (l+r)/2;
        return min(query(2*curr,l,mid,tl,tr),query(2*curr+1,mid+1,r,tl,tr));
    }
};
segtree seg1,seg2,seg3;
int main(){
    long long n,Q,a,b;
    cin>>n>>Q>>a>>b;
    for(long long i=1;i<=Q;i++){
        cin>>q[i];
    }
    seg1.build(1,1,n);
    seg2.build(1,1,n);
    seg3.build(1,1,n);
    seg1.insert(1,1,n,a,abs(b-q[1]));
    seg2.insert(1,1,n,a,abs(b-q[1])+a);
    seg3.insert(1,1,n,a,abs(b-q[1])-a);
    seg1.insert(1,1,n,b,abs(a-q[1]));
    seg2.insert(1,1,n,b,abs(a-q[1])+b);
    seg3.insert(1,1,n,b,abs(a-q[1])-b);
    //cout<<seg1.query(1,1,n,1,n)<<endl;
    for(long long i=2;i<=Q;i++){
        long long val = seg2.query(1,1,n,q[i],n)-q[i];
        val = min(val,seg3.query(1,1,n,1,q[i]-1)+q[i]);
        seg1.update(1,1,n,1,n,abs(q[i]-q[i-1]));
        seg2.update(1,1,n,1,n,abs(q[i]-q[i-1]));
        seg3.update(1,1,n,1,n,abs(q[i]-q[i-1]));
        seg1.insert(1,1,n,q[i-1],val);
        seg2.insert(1,1,n,q[i-1],val+q[i-1]);
        seg3.insert(1,1,n,q[i-1],val-q[i-1]);
    }
    cout<<seg1.query(1,1,n,1,n)<<endl;
}
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 200005;
const LL INF = 0x3f3f3f3f3f3f3f3f;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

template <typename T> inline void cmin(T &x, T y) {
	if (x > y) x = y;
}

template <typename T> inline void cmax(T &x, T y) {
	if (x < y) x = y;
}

int n, q, A, B, p[MAXN];
LL csum[MAXN], dp[MAXN];

struct BIT {
	LL tr[MAXN];
	BIT() {
		mset(tr, 0x3f);
	}
	inline int lowbit(int x) {
		return x & (-x);
	}
	inline void update(int x, LL val) {
		for (int i=x;i<=n;i+=lowbit(i)) {
			cmin(tr[i], val);
		}
	}
	inline LL query(int x) {
		LL ret = INF;
		for (int i=x;i;i-=lowbit(i)) {
			cmin(ret, tr[i]);
		}
		return ret;
	}
}t1, t2;

void init() {
	read(n); read(q);
	read(A); read(B);
	for (int i=1;i<=q;++i) {
		read(p[i]);
	}
	for (int i=2;i<=q;++i) {
		csum[i] = csum[i-1] + abs(p[i]-p[i-1]);
	}
}

void solve() {
	dp[0] = min(abs(A-p[1]), abs(B-p[1]));
	t1.update(A, abs(B-p[1]) - A);
	t2.update(n-A+1, abs(B-p[1]) + A);
	t1.update(B, abs(A-p[1]) - B);
	t2.update(n-B+1, abs(A-p[1]) + B);
	for (int i=1;i<q;++i) {
		dp[i] = min( t1.query(p[i+1]) + csum[i] + p[i+1], 
					 t2.query(n-p[i+1]+1) + csum[i] - p[i+1] );
		t1.update(p[i], dp[i] - csum[i+1] - p[i]);
		t2.update(n-p[i]+1, dp[i] - csum[i+1] + p[i]);
	}
	LL ans = INF;
	for (int i=0;i<q;++i) {
		cmin(ans, dp[i] + csum[q] - csum[i+1]);
	}
	printf("%lld\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}
