#include <cstdio>
typedef long long ll;

template<class T> inline T Abs(const T x){return x>=0?x:-x;}
template<class T> inline T Min(const T a,const T b){return a<b?a:b;}

int n,m,x,y;
ll AT,f[200005],f1[200005],f2[200005],Ans;
const ll Inf=1e18;

void Add1(int x,ll k){for(;x<=n&&k<f1[x];x+=x&-x)f1[x]=k;}
ll Query1(int x,ll k=Inf){for(;x;x^=x&-x)k=Min(k,f1[x]);return k;}
void Add2(int x,ll k){for(;x&&k<f2[x];x^=x&-x)f2[x]=k;}
ll Query2(int x,ll k=Inf){for(;x<=n;x+=x&-x)k=Min(k,f2[x]);return k;}

int main()
{
    scanf("%d%d%d%d",&n,&m,&x,&y),Ans=Inf;
    for(int i=1;i<=n;++i)f[i]=f1[i]=f2[i]=Inf;
    for(f[y]=0,Add1(y,-y),Add2(y,y);m--;)
    {
        y=x,scanf("%d",&x);
        ll v=Min(Query1(x)+x,Query2(x)-x)+AT;
        AT+=Abs(x-y);
        if(v-AT<f[y])f[y]=v-AT,Add1(y,f[y]-y),Add2(y,f[y]+y);
    }
    for(int i=1;i<=n;++i)Ans=Min(Ans,f[i]);
    return printf("%lld\n",Ans+AT),0;
}
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 200010
ll n, q, c, x[N];
set<P> dp[2];

int main(){
	cin>>n>>q>>x[0]>>c;
	rep(i, q) cin>>x[i+1];
	dp[0].insert(P(c, 0));
	for(int i = 1; i <= q; i++){
		int t = i%2;
		dp[t].clear();
		for(auto p: dp[!t]){
			dp[t].insert(P(x[i-1], p.snd+abs(x[i]-p.fst)));
			dp[t].insert(P(p.fst, p.snd+abs(x[i]-x[i-1])));
		}
		{
			auto it = dp[t].begin(), it2 = it; ++it2;
			while(it2!=dp[t].end()){
				while(it2!=dp[t].end() && it->snd+abs(it->fst-it2->fst)<=it2->snd){
					dp[t].erase(it2);
					it2 = it;
					++it2;
				}
				++it;
				if(it2!=dp[t].end()) ++it2;
			}
		}
		{
			auto it = dp[t].end();
			if(it!=dp[t].begin()) --it;
			auto it2 = it;
			if(it!=dp[t].begin()) --it2;
			while(it!=dp[t].begin()){
				while(it!=dp[t].begin() && it->snd+abs(it->fst-it2->fst)<=it2->snd){
					dp[t].erase(it2);
					it2 = it;
					if(it2!=dp[t].begin()) --it2;
				}
				if(it!=dp[t].begin()){
					--it;
					if(it2!=dp[t].begin()) --it2;
				}
			}
		}
	}
	ll res = 1e17;
	for(auto p: dp[q%2]) res = min(res, p.snd);
	cout<<res<<endl;
	return 0;
}
