// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define fbo find_by_order

#define ook order_of_key



typedef long long ll;

typedef pair<ll,ll> ii;

typedef vector<ll> vi;

typedef long double ld; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

typedef set<int>::iterator sit;

typedef map<int,int>::iterator mit;

typedef vector<int>::iterator vit;



ll a[200001];



struct node

{

	ll lazy;

	ll ans;

};



node st[2][3][800001];

int N,n; ll x,y; 



void combine(int i1, int i2, int id)

{

	st[i1][i2][id].ans=min(st[i1][i2][id*2].ans,st[i1][i2][id*2+1].ans);

}



void build(int i1, int i2, int id, int l, int r)

{

	if(r-l<2)

	{

		ll val = ll(1e12);

		if(i1==0&&l==x) val=abs(a[1]-y);

		else if(i1==1&&l==y) val=abs(a[1]-x);

		if(i2==1) val+=(N-1-l);

		if(i2==2) val+=l;

		st[i1][i2][id].ans=val;

		st[i1][i2][id].lazy=0;

		return ;

	}

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

	build(i1,i2,id*2,l,mid);

	build(i1,i2,id*2+1,mid,r);

	combine(i1,i2,id);

}



void push(int i1, int i2, int id, int l, int r)

{

	if(st[i1][i2][id].lazy!=0)

	{

		st[i1][i2][id].ans+=st[i1][i2][id].lazy;

		if(r-l>=2)

		{

			st[i1][i2][id*2].lazy+=st[i1][i2][id].lazy;

			st[i1][i2][id*2+1].lazy+=st[i1][i2][id].lazy;

		}

		st[i1][i2][id].lazy=0;

	}

}



void update(int i1, int i2, int id, int l, int r, int ql, int qr, ll val)

{

	push(i1,i2,id,l,r);

	if(ql>=r||l>=qr) return ;

	if(ql<=l&&r<=qr)

	{

		//cerr<<l<<' '<<r<<' '<<ql<<' '<<qr<<'\n';

		st[i1][i2][id].lazy+=val;

		push(i1,i2,id,l,r);

		//cerr<<id<<' '<<l<<' '<<r<<' '<<st[i1][i2][id].ans<<'\n';

		return ;

	}

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

	update(i1,i2,id*2,l,mid,ql,qr,val);

	update(i1,i2,id*2+1,mid,r,ql,qr,val);

	combine(i1,i2,id);

	//cerr<<id<<' '<<l<<' '<<r<<' '<<st[i1][i2][id].ans<<'\n';

}



ll query(int i1, int i2, int id, int l, int r, int ql, int qr)

{

	push(i1,i2,id,l,r);

	if(ql>=r||l>=qr) return ll(5e18);

	if(ql<=l&&r<=qr)

	{

		return st[i1][i2][id].ans;

	}

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

	return min(query(i1,i2,id*2,l,mid,ql,qr),query(i1,i2,id*2+1,mid,r,ql,qr));

}



ll queryabs(int i1, ll pos)

{

	ll v1 = query(i1,1,1,0,N,0,pos+1)-(N-1-pos);

	ll v2 = query(i1,2,1,0,N,pos,N)-pos;

	return min(v1,v2);

}



int main()

{

	ios_base::sync_with_stdio(0); cin.tie(0);

	cin>>N>>n>>x>>y;

	x--; y--;

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

	{

		cin>>a[i];

		a[i]--;

	}

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

	{

		for(int j=0;j<3;j++)

		{

			build(i,j,1,0,N);

		}

	}

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

	{

		ll cur0 = queryabs(1,a[i]);

		ll cur1 = queryabs(0,a[i]);

		for(int j=0;j<2;j++)

		{

			for(int k=0;k<3;k++)

			{

				update(j,k,1,0,N,0,N,abs(a[i]-a[i-1]));

			}

		}

		ll z[3]; ll diff[3];

		for(int j=0;j<3;j++) z[j] = query(0,j,1,0,N,a[i-1],a[i-1]+1);

		diff[1]=N-1-a[i-1];

		diff[0]=0;

		diff[2]=a[i-1];

		if(cur0<z[0])

		{

			for(int k=0;k<3;k++)

			{

				update(0,k,1,0,N,a[i-1],a[i-1]+1,cur0+diff[k]-z[k]);

			}

		}

		{

			ll ans = query(0,0,1,0,N,0,N);

			ll ans2 = query(1,0,1,0,N,0,N);

			//cerr<<i<<' '<<ans<<' '<<ans2<<'\n';

		}

		////cerr<<query(0,0,1,0,N,a[i-1],a[i-1]+1)<<'\n';

		for(int j=0;j<3;j++) z[j] = query(1,j,1,0,N,a[i-1],a[i-1]+1);

		if(cur1<z[0])

		{

			for(int k=0;k<3;k++)

			{

				//cerr<<query(1,0,1,0,N,0,N)<<'\n';

				//cerr<<query(1,k,1,0,N,a[i-1],a[i-1]+1)+cur1+diff[k]-z[k]<<'\n';

				update(1,k,1,0,N,a[i-1],a[i-1]+1,cur1+diff[k]-z[k]);

				//cerr<<query(1,0,1,0,N,0,N)<<'\n';

				//cerr<<query(1,k,1,0,N,a[i-1],a[i-1]+1)<<'\n';

			}

		}

		//cerr<<a[i-1]<<'\n';

		{

			ll ans = query(0,0,1,0,N,0,N);

			ll ans2 = query(1,0,1,0,N,0,N);

			//cerr<<i<<' '<<ans<<' '<<ans2<<'\n';

		}

		////cerr<<query(1,0,1,0,N,a[i-1],a[i-1]+1)<<'\n';

		ll ans = query(0,0,1,0,N,0,N);

		ll ans2 = query(1,0,1,0,N,0,N);

		//cerr<<i<<' '<<ans<<' '<<ans2<<'\n';

	}

	ll ans = query(0,0,1,0,N,0,N);

	ll ans2 = query(1,0,1,0,N,0,N);

	cout<<min(ans,ans2)<<'\n';

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#include<cstring>

#define MN 200005

using namespace std;

typedef long long ll;

int n,q;

ll mk[MN<<2];

struct node{

	ll mi[4];

	friend node operator+(node x,node y){

		node z;

		for(int i=1;i<=3;i++)z.mi[i]=min(x.mi[i],y.mi[i]);

		return z;

	}

}T[MN<<2];

void uadd(int v){for(int i=1;i<=3;i++)T[1].mi[i]+=v;mk[1]+=v;}

void pushdown(int k,int l,int r){

	mk[k<<1]+=mk[k],mk[k<<1|1]+=mk[k];

	for(int i=1;i<=3;i++)T[k<<1].mi[i]+=mk[k],T[k<<1|1].mi[i]+=mk[k];mk[k]=0;

}

void update(int l,int r,int a,int k,ll ad){

	if(l==r)return (void)(T[k].mi[1]>ad?(T[k].mi[1]=ad,T[k].mi[2]=ad-l,T[k].mi[3]=ad+l):0);if(mk[k])pushdown(k,l,r);int mid=(l+r)>>1;

	if(a<=mid)update(l,mid,a,k<<1,ad);else update(mid+1,r,a,k<<1|1,ad);T[k]=T[k<<1]+T[k<<1|1];

}

ll que1(int l,int r,int a,int b,int k){

	if(l==a&&r==b)return T[k].mi[2];if(mk[k])pushdown(k,l,r);int mid=(l+r)>>1;

	if(b<=mid)return que1(l,mid,a,b,k<<1);if(a>mid)return que1(mid+1,r,a,b,k<<1|1);

	return min(que1(l,mid,a,mid,k<<1),que1(mid+1,r,mid+1,b,k<<1|1));

}

ll que2(int l,int r,int a,int b,int k){

	if(l==a&&r==b)return T[k].mi[3];if(mk[k])pushdown(k,l,r);int mid=(l+r)>>1;

	if(b<=mid)return que2(l,mid,a,b,k<<1);if(a>mid)return que2(mid+1,r,a,b,k<<1|1);

	return min(que2(l,mid,a,mid,k<<1),que2(mid+1,r,mid+1,b,k<<1|1));

}

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

	if(l==r)return (void)(T[k].mi[1]=T[k].mi[2]=T[k].mi[3]=1e18);int mid=(l+r)>>1;

	build(l,mid,k<<1);build(mid+1,r,k<<1|1);T[k]=T[k<<1]+T[k<<1|1];

}

int main(){

	int a,b;scanf("%d%d%d%d",&n,&q,&a,&b);build(1,n,1);

	update(1,n,b,1,0);

	int lst=a,x;

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

		scanf("%d",&x);

		ll tmp=min(que1(1,n,1,x,1)+x,que2(1,n,x,n,1)-x);

		uadd(abs(x-lst));update(1,n,lst,1,tmp);lst=x;

	}printf("%lld\n",T[1].mi[1]);

}

// Fastest known solution for this problem: