#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=200005;
int n,Q,S1,S2,a[N];
ll s[N],dp[N],ans;
struct wzpakking{
	ll c[N];
	void change(int x,ll v){
		for (;x<=n;x+=x&(-x))
			c[x]=min(c[x],v);
	}
	ll ask(int x){
		ll s=4e18;
		for (;x;x-=x&(-x))
			s=min(s,c[x]);
		return s;
	}
}T[2];
void insert(ll v,int p){
	T[0].change(p,v-p);
	T[1].change(n-p+1,v+p);
}
int main(){
	scanf("%d%d%d%d",&n,&Q,&S1,&S2);
	for (int i=1;i<=Q;i++) scanf("%d",&a[i]);
	for (int i=2;i<=Q;i++) s[i]=s[i-1]+abs(a[i]-a[i-1]);
	for (int i=1;i<=n;i++) T[0].c[i]=T[1].c[i]=4e18;
	insert(abs(S1-a[1]),S2);
	insert(abs(S2-a[1]),S1);
	ans=s[Q]+min(abs(S1-a[1]),abs(S2-a[1]));
	for (int i=2;i<=Q;i++){
		dp[i-1]=min(T[0].ask(a[i])+a[i],T[1].ask(n-a[i]+1)-a[i])+s[i-1];
		ans=min(ans,dp[i-1]+s[Q]-s[i]);
		insert(dp[i-1]-s[i],a[i-1]);
	}
	printf("%lld",ans);
}