#include<bits/stdc++.h>
using namespace std;
const long long INF=1e18;
int n,T,a,b,p[200010];
long long td[200010],pm[2][2][200010],dp[2][200010],ans=INF;
void Add(long long*s,int x,long long v){
	while(x<=n)s[x]=min(s[x],v),x+=(x&-x);
}
long long Query(long long*s,int x){
	long long ret=INF;
	while(x)ret=min(ret,s[x]),x-=(x&-x);
	return ret;
}
int main(){
	scanf("%d%d%d%d",&n,&T,&a,&b);
	for(int i=1;i<=T;++i)scanf("%d",&p[i]),i>1?td[i]=td[i-1]+abs(p[i]-p[i-1]):0;
	for(int i=1;i<=n;++i)pm[0][0][i]=pm[0][1][i]=pm[1][0][i]=pm[1][1][i]=INF;
	dp[0][1]=abs(a-p[1]),dp[1][1]=abs(b-p[1]),ans=min(ans,min(dp[0][1]+td[T],dp[1][1]+td[T]));
	Add(pm[0][0],b,dp[0][1]-b),Add(pm[0][1],n-b+1,dp[0][1]+b);
	Add(pm[1][0],a,dp[1][1]-a),Add(pm[1][1],n-a+1,dp[1][1]+a);
	for(int i=2;i<=T;++i){
		dp[0][i]=min(Query(pm[0][0],p[i])+p[i]+td[i-1],Query(pm[0][1],n-p[i])-p[i]+td[i-1]);
		dp[1][i]=min(Query(pm[1][0],p[i])+p[i]+td[i-1],Query(pm[1][1],n-p[i])-p[i]+td[i-1]);
		Add(pm[0][0],p[i-1],dp[0][i]-td[i]-p[i-1]),Add(pm[0][1],n-p[i-1]+1,dp[0][i]-td[i]+p[i-1]);
		Add(pm[1][0],p[i-1],dp[1][i]-td[i]-p[i-1]),Add(pm[1][1],n-p[i-1]+1,dp[1][i]-td[i]+p[i-1]);
		ans=min(ans,min(dp[0][i]+td[T]-td[i],dp[1][i]+td[T]-td[i]));
	}
	printf("%lld",ans);
	return 0;
}