// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

#define ll long long

#define MAX 200200

#define lson (now<<1)

#define rson (now<<1|1)

inline int read()

{

	int x=0;bool t=false;char ch=getchar();

	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();

	if(ch=='-')t=true,ch=getchar();

	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();

	return t?-x:x;

}

int n,Q,A,B,a[MAX];ll f[MAX];

struct SegMentTree

{

	ll t[MAX<<2],tag[MAX<<2],a[MAX];

	void pushup(int now){t[now]=min(t[lson],t[rson]);}

	void Build(int now,int l,int r)

	{

		if(l==r){t[now]=f[l]+a[l];return;}

		int mid=(l+r)>>1;tag[now]=0;

		Build(lson,l,mid);Build(rson,mid+1,r);

		pushup(now);

	}

	void puttag(int now,ll w){t[now]+=w;tag[now]+=w;}

	void pushdown(int now)

	{

		if(!tag[now])return;

		puttag(lson,tag[now]);

		puttag(rson,tag[now]);

		tag[now]=0;

	}

	void Modify(int now,int l,int r,int p,ll w)

	{

		if(l==r){t[now]=min(t[now],w);return;}

		int mid=(l+r)>>1;pushdown(now);

		if(p<=mid)Modify(lson,l,mid,p,w);

		else Modify(rson,mid+1,r,p,w);

		pushup(now);

	}

	void Modify(int now,int l,int r,int L,int R,int w)

	{

		if(L<=l&&r<=R){puttag(now,w);return;}

		int mid=(l+r)>>1;pushdown(now);

		if(L<=mid)Modify(lson,l,mid,L,R,w);

		if(R>mid)Modify(rson,mid+1,r,L,R,w);

		pushup(now);

	}

	ll Query(int now,int l,int r,int L,int R)

	{

		if(L<=l&&r<=R)return t[now];

		int mid=(l+r)>>1;ll ret=4e18;pushdown(now);

		if(L<=mid)ret=min(ret,Query(lson,l,mid,L,R));

		if(R>mid)ret=min(ret,Query(rson,mid+1,r,L,R));

		return ret;

	}

}T1,T2;

ll Solve(int A,int B)

{

	memset(f,63,sizeof(f));f[B]=abs(A-a[1]);

	for(int i=1;i<=n;++i)T1.a[i]=-i,T2.a[i]=i;

	T1.Build(1,1,n);T2.Build(1,1,n);

	ll inf=f[0];f[B]=inf;f[1]=abs(A-a[1]);

	for(int i=2;i<=Q;++i)

	{

		ll ret=inf;

		ret=min(ret,T1.Query(1,1,n,1,a[i])+a[i]);

		ret=min(ret,T2.Query(1,1,n,a[i],n)-a[i]);

		T1.Modify(1,1,n,1,n,abs(a[i]-a[i-1]));

		T2.Modify(1,1,n,1,n,abs(a[i]-a[i-1]));

		T1.Modify(1,1,n,a[i-1],ret-a[i-1]);

		T2.Modify(1,1,n,a[i-1],ret+a[i-1]);

		ret=min(ret,f[i-1]+abs(a[i]-a[i-1]));

		f[i]=ret;

	}

	return f[Q];

}

int main()

{

	n=read();Q=read();A=read();B=read();

	for(int i=1;i<=Q;++i)a[i]=read();

	printf("%lld\n",min(Solve(A,B),Solve(B,A)));

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.123422527171229x):
/********************************************************************************

	

	Code by a weak man named CYJian, and he hopes the code can get more points.



	Algorithm: 



 ********************************************************************************/



#include <bits/stdc++.h>



using namespace std;



typedef long long ll;



//{{{ FAST IO AND SOME FUNCTIONS

const int __SIZE = 1 << 18;

char ibuf[__SIZE], *iS, *iT;



#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)

#define ri read_int()

#define rl read_ll()

#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)



template<typename T>

inline void read(T &x) {

	char ch, t = 0; x = 0;

	while(!isdigit(ch = ge)) t |= ch == '-';

	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;

	x = t ? -x : x;

}

inline int read_int() { int x; return read(x), x; }

inline ll read_ll() { ll x; return read(x), x; }



template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }

template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }

//}}}



const int MAXN = 200010;

const ll inf = 1e18;



struct Segment_Tree {

#define ls (x << 1)

#define rs (x << 1 | 1)



	struct Node { ll v1, v2, v3, t; } T[MAXN << 2];



	inline void pushup(int x) {

		T[x].v1 = min(T[ls].v1, T[rs].v1);

		T[x].v2 = min(T[ls].v2, T[rs].v2);

		T[x].v3 = min(T[ls].v3, T[rs].v3);

	}



	inline void Pls(int x, ll v) { T[x].v1 += v, T[x].v2 += v, T[x].v3 += v, T[x].t += v; }

	inline void pushdown(int x) { if(T[x].t) Pls(ls, T[x].t), Pls(rs, T[x].t), T[x].t = 0; }



	inline void build(int x, int l, int r, int p) {

		if(l == r) return p == l ? 0 : T[x].v1 = T[x].v2 = T[x].v3 = inf, T[x].v1 -= l, T[x].v3 += l, void();

		int mid = (l + r) >> 1; build(ls, l, mid, p), build(rs, mid + 1, r, p), pushup(x);

	}



	inline void Add(int x, int l, int r, int L, int R, int v) {

		if(L <= l && r <= R) return Pls(x, v);

		int mid = (l + r) >> 1; pushdown(x);

		if(L <= mid) Add(ls, l, mid, L, R, v);

		if(mid < R) Add(rs, mid + 1, r, L, R, v);

		pushup(x);

	}



	inline void Give(int x, int l, int r, int p, ll v) {

		if(l == r) return T[x].v1 = T[x].v2 = T[x].v3 = v, T[x].v1 -= l, T[x].v3 += l, void();

		int mid = (l + r) >> 1; pushdown(x);

		p <= mid ? Give(ls, l, mid, p, v) : Give(rs, mid + 1, r, p, v);

		pushup(x);

	}



	inline ll Q(int x, int l, int r, int L, int R, int k) {

		if(L <= l && r <= R) return k == 1 ? T[x].v1 : (k == 2 ? T[x].v2 : T[x].v3);

		int mid = (l + r) >> 1; pushdown(x);

		if(R <= mid) return Q(ls, l, mid, L, R, k);

		if(mid < L) return Q(rs, mid + 1, r, L, R, k);

		return min(Q(ls, l, mid, L, R, k), Q(rs, mid + 1, r, L, R, k));

	}



#undef ls

#undef rs

}seg;



int main() {

#ifdef LOCAL

	FILE("");

#endif



	int n = ri, q = ri, A = ri, B = ri, las;



	seg.build(1, 1, n, A), las = B;

	for(int i = 1; i <= q; i++) {

		int x = ri;

		ll f = min(seg.Q(1, 1, n, 1, x, 1) + x, seg.Q(1, 1, n, x, n, 3) - x);

		seg.Give(1, 1, n, las, f);

		if(las > 1) seg.Add(1, 1, n, 1, las - 1, abs(x - las));

		if(las < n) seg.Add(1, 1, n, las + 1, n, abs(x - las));

		las = x;

	} cout << seg.Q(1, 1, n, 1, n, 2);

	return 0;

}