// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define maxn 200010

const long long INF=1e18;

template <typename T>inline T read()

{

    register T sum=0;

    register char cc=getchar();

    int sym=1;

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

    if(cc=='-')sym=-1,cc=getchar();

    sum=sum*10+cc-'0';

    cc=getchar();

    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();

    return sym*sum;

}

template <typename T>inline T read(T &a)

{

    a=read<T>();

    return a;

}

template <typename T,typename... Others> inline void read(T& a, Others&... b)

{

    a=read(a);

	read(b...);

}

int n,m,A,B,x[maxn];

long long f[maxn],tag[maxn<<2],val[maxn<<2][3];

void Effect(int k,long long v)

{

	for(int i:{0,1,2})

		val[k][i]+=v;

	tag[k]+=v;

}

void down(int k)

{

	if(tag[k])

	{

		Effect(k<<1,tag[k]);

		Effect(k<<1|1,tag[k]);

		tag[k]=0;

	}

}

void update(int k)

{

	for(int i:{0,1,2})

		val[k][i]=min(val[k<<1][i],val[k<<1|1][i]);

}

void build(int k,int l,int r)

{

	if(l==r)

	{

		val[k][0]=f[l];

		val[k][1]=f[l]+l;

		val[k][2]=f[l]-l;

		return ;

	}

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

	build(k<<1,l,mid);

	build(k<<1|1,mid+1,r);

	update(k);

}

void change(int k,int l,int r,int x,long long y)

{

	if(l==r)

	{

		if(y<val[k][0])

		{

			val[k][0]=y;

			val[k][1]=y+l;

			val[k][2]=y-l;

		}

		return ;

	}

	down(k);

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

	if(x<=mid)change(k<<1,l,mid,x,y);

	else change(k<<1|1,mid+1,r,x,y);

	update(k);

}

long long query(int k,int l,int r,int x,int y,int op)

{

	if(l>=x&&r<=y)

		return val[k][op];

	down(k);

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

	long long res=INF;

	if(x<=mid)res=min(res,query(k<<1,l,mid,x,y,op));

	if(y>mid)res=min(res,query(k<<1|1,mid+1,r,x,y,op));

	return res;

}

int main()

{

	read(n,m,A,B);

	for(int i=1;i<=m;i++)

		read(x[i]);

	memset(f+1,0x7f,sizeof(long long)*n);

	f[A]=min(f[A],1ll*abs(B-x[1]));

	f[B]=min(f[B],1ll*abs(A-x[1]));

	build(1,1,n);

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

	{

		long long v=query(1,1,n,1,x[i],2)+x[i];

		if(x[i]<n)v=min(v,query(1,1,n,x[i]+1,n,1)-x[i]);

		Effect(1,abs(x[i]-x[i-1]));

		change(1,1,n,x[i-1],v);

	}

	printf("%lld\n",val[1][0]);

    return 0;

}


// Fastest known solution for this problem: