#include<bits/stdc++.h>
using namespace std;
#define Set(a,b) memset(a,b,sizeof(a))
template<class T>inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}typedef long long ll;
const int N=2e5+10;
const int MAXN=N<<2;
const ll INF=1e17;
int m,A,B,n,X[N];ll dp[N];
ll S[N],ans=INF;
#define ls (u<<1)
#define rs (u<<1|1)
#define MID (l+r)>>1
ll T1[N<<2],T2[N<<2];
void Rebuild(int u,int l,int r){
	T1[u]=T2[u]=INF;
	if(l==r) return;
	int mid=MID;
	Rebuild(ls,l,mid),Rebuild(rs,mid+1,r);
}
inline void Insert(int u,int l,int r,int p,ll x){
	T1[u]=min(T1[u],x-p),T2[u]=min(T2[u],x+p);
	if(l==r) return;int mid=MID;
	if(mid>=p) Insert(ls,l,mid,p,x);
	else       Insert(rs,mid+1,r,p,x);
	return;
}
ll Query(int u,int l,int r,int L,int R,const ll*T){
	if(L>R) return INF;
	if(l>=L&&r<=R) return T[u];
	int mid=MID;
	if(mid>=R) return Query(ls,l,mid,L,R,T);
	if(mid< L) return Query(rs,mid+1,r,L,R,T);
	return min(Query(ls,l,mid,L,mid,T),Query(rs,mid+1,r,mid+1,R,T));
}
inline void Solve(int A,int B){
	X[0]=A;Rebuild(1,1,n);dp[1]=abs(X[1]-B);
	ans=min(ans,dp[1]+S[m]),Insert(1,1,n,X[0],dp[1]);
	for(int i=2;i<=m;++i) {int x=X[i];
		ll L=Query(1,1,n,1,x,T1);
		ll R=Query(1,1,n,x,n,T2);
		dp[i]=min(L+x,R-x)+S[i-1];
		Insert(1,1,n,X[i-1],dp[i]-S[i]);
		ans=min(ans,dp[i]+S[m]-S[i]);
	}return;
}
int main()
{
	init(n),init(m),init(A),init(B);
	for(int i=1;i<=m;++i) init(X[i]);
	for(int i=2;i<=m;++i) S[i]=S[i-1]+abs(X[i]-X[i-1]);
	Solve(A,B),Solve(B,A),cout<<ans<<endl;
	return 0;
}
