#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 200005;
ll f[maxn << 2], fa[maxn << 2], fb[maxn << 2], tag;

void modify(int now, int L, int R, int p, ll x) {
	f[now] = std::min(f[now], x);
	fa[now] = std::min(fa[now], x + p);
	fb[now] = std::min(fb[now], x - p);
	if(L == R) return;
	int M = (L + R) >> 1;
	if(p <= M) modify(now << 1, L, M, p, x);
	else modify(now << 1 | 1, M + 1, R, p, x);
}

void build(int now, int L, int R) {
	f[now] = fa[now] = fb[now] = 1000000000000000000;
	if(L == R) return;
	int M = (L + R) >> 1;
	build(now << 1, L, M);
	build(now << 1 | 1, M + 1, R);
}

ll query(int now, int L, int R, int p) {
	if(R < p) return p + fb[now];
	if(L > p) return fa[now] - p;
	if(L == R) return f[now];
	int M = (L + R) >> 1;
	return std::min(query(now << 1, L, M, p), query(now << 1 | 1, M + 1, R, p));
}

void test(int now, int L, int R) {
	/* debug("%d-%d : %lld (+)%lld (-)%lld\n", */
	/* 		L, R, f[now] + tag, fa[now] + tag, fb[now] + tag); */
	if(L == R) {
		/* if(f[now] >= 1000000000) */
		/* 	debug(" inf"); */
		/* else */
		/* 	debug(" %lld", f[now] + tag); */
		return;
	}
	int M = (L + R) >> 1;
	test(now << 1, L, M);
	test(now << 1 | 1, M + 1, R);
}

int main() {
	int n = read, q = read, a = read, b = read;

	build(1, 1, n);
	modify(1, 1, n, a, 0);
	/* modify(1, 1, n, b, 0); */

	int last = b;
	while(q --) {
		int x = read;
		ll qu = query(1, 1, n, x) + tag;
		/* debug("qu = %lld\n", qu); */
		tag += std::abs(x - last);
		modify(1, 1, n, last, qu - tag);
		last = x;
		/* debug("tag=%lld\n", tag); */
		/* test(1, 1, n); debug("\n"); */
	}

	printf("%lld\n", f[1] + tag);
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=200005;
int n,q,x,y,a[N];
ll sum[N],dp[N],ans;
#define lowbit(i) i&-i
struct BIT{
	ll c[N];
	void change(int pos,ll de){
		for(int i=pos;i<=n;i+=lowbit(i))c[i]=min(c[i],de);
	}
	ll ask(int pos){
		ll ans=4e18;
		for(int i=pos;i;i-=lowbit(i))ans=min(ans,c[i]);
		return ans;
	}
}T[2];
void insert(ll de,int pos){
	T[0].change(pos,de-pos);
	T[1].change(n-pos+1,de+pos);
}
int main(){
	n=read(); q=read(); x=read(); y=read();
	for(int i=1;i<=q;i++)a[i]=read();
	for(int i=2;i<=q;i++)sum[i]=sum[i-1]+abs(a[i-1]-a[i]);
	for(int i=1;i<=n;i++)T[0].c[i]=T[1].c[i]=4e18;
	insert(abs(x-a[1]),y);
	insert(abs(y-a[1]),x);
	ans=sum[q]+min(abs(x-a[1]),abs(y-a[1]));
	for(int i=1;i<q;i++){
		dp[i]=min(T[0].ask(a[i+1])+sum[i]+a[i+1],T[1].ask(n-a[i+1]+1)+sum[i]-a[i+1]);
		//if(i==3)cout<<dp[i]<<" "<<i<<" "<<T[0].ask(a[i+1])<<endl;
		//cout<<ans<<endl;
		ans=min(ans,dp[i]+sum[q]-sum[i+1]);
		insert(dp[i]-sum[i+1],a[i]);
	}
	cout<<ans<<endl;
}
/*
dp[i]=dp[j]+sum[i]-sum[j+1]+abs(a[i+1]-a[j])
*/