#include <bits/stdc++.h>

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 2e5 + 10;

typedef long long LL;

void chkmin(LL &x, LL y){ x = x < y ? x : y; }

struct Segment_Tree{
	
	LL Min[N << 2], Min_neg[N << 2], Min_pos[N << 2];

	#define lc (o << 1)
	#define rc (o << 1 | 1)
	#define M ((L + R) >> 1)

	void init(){
		memset(Min, 0x3f, sizeof Min);
		memset(Min_neg, 0x3f, sizeof Min_neg);
		memset(Min_pos, 0x3f, sizeof Min_pos);
	}

	void update(int o, int L, int R, int x, LL val){
		chkmin(Min[o], val);
		chkmin(Min_neg[o], val - x);
		chkmin(Min_pos[o], val + x);
		if(L ^ R){
			if(x <= M) update(lc, L, M, x, val);
			else update(rc, M + 1, R, x, val);
		}
	}

	LL query(LL *val, int o, int L, int R, int l, int r){
		if(l <= L && R <= r) return val[o];
		else{
			LL ret = 1ll << 60;
			if(l <= M) chkmin(ret, query(val, lc, L, M, l, r));
			if(r > M) chkmin(ret, query(val, rc, M + 1, R, l, r));
			return ret;
		}
	}

}T;

int n, q, A, B;
int X[N];

int main(){

	scanf("%d%d%d%d", &n, &q, &A, &B);
	For(i, 1, q) scanf("%d", &X[i]);

	LL sum = 0;
	T.init();
	T.update(1, 1, n, A, abs(B - X[1])), T.update(1, 1, n, B, abs(A - X[1]));

	For(i, 2, q){
		int d = abs(X[i] - X[i - 1]);
		sum += d;

		LL ret = min(T.query(T.Min_pos, 1, 1, n, X[i], n) - X[i],
					  T.query(T.Min_neg, 1, 1, n, 1, X[i]) + X[i]) - d;
		T.update(1, 1, n, X[i - 1], ret);
	}

	printf("%lld\n", T.Min[1] + sum);
	return 0;
}