// #includes {{{
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;


typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

const Int INF=0x3f3f3f3f3f3f3f3fll;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

//{{{ Segment Tree
template <class T>
struct segment_tree {
	int n;
	vector<T> x, d;
	segment_tree(int n_) {
		n=1;
		while(n < n_)n*=2;
		x.assign(n*2,init_val());
		d.assign(n*2,0);
	}

	T init_val(){
		return INF;
	}
	T f(const T &a, const T &b){
		return min(a,b);
	}
	T range(int a,int b,int i,int l,int r){
		if(r<=a or b<=l)return init_val();
		if(a<=l and r<=b)return x[i] + d[i];
		else{
			push(i,l,r);
			update(i,l,r);
			assert(d[i]==0);
			int m = (l+r)/2;
			return f(range(a,b,i*2+1,l,m),range(a,b,i*2+2,m,r));
		}
	}
	T range(int a,int b){
		return range(a,b,0,0,n);
	}
	void add(int a,int b,T diff,int i,int l,int r){
		if(r<=a or b<=l)return;
		if(a<=l and r<=b)d[i]+=diff;
		else{
			push(i,l,r);
			int m = (l+r)/2;
			add(a,b,diff,i*2+1,l,m);
			add(a,b,diff,i*2+2,m,r);
			update(i,l,r);
		}
	}
	void add(int a,int b,T diff){
		add(a,b,diff,0,0,n);
	}

	void push(int i,int l,int r){
		int i0 = i*2+1, i1 = i*2+2;
		assert(r-l>1);
		if(x[i0]<INF) d[i0]+=d[i];
		if(x[i1]<INF) d[i1]+=d[i];
		d[i] = 0;
		
//		update(i,l,r);
	}
	void update(int i,int l,int r){
		x[i] = f(d[i*2+1]+x[i*2+1],d[i*2+2]+x[i*2+2]);
	}
	void set(int a,const T &v,int i,int l,int r){
		if(r-l==1){
			d[i] = 0;
			x[i] = v;
		}else{
			push(i,l,r);
			int m = (l+r)/2;
			if(a<m)set(a,v,i*2+1,l,m);
			else set(a,v,i*2+2,m,r);
			update(i,l,r);
		}
	}
	void set(int a,const T &v){
		set(a,v,0,0,n);
	}
};
//}}}

//const Int INF = 1e+18;
int N,Q,A,B;
Int x[200010];
Int allA, allB;

void test(){
	segment_tree<Int> st(20);
	st.set(0,3);
	st.set(1,4);
	st.set(2,2);
	st.set(3,1);
	st.set(4,5);
	cout<<st.range(0,5)<<endl;
	st.add(0,4,100);
	cout<<st.range(0,5)<<endl;
	st.set(3,24);
	cout<<st.range(0,5)<<endl;
}

int main(){
//	test();
//	return 0;
	Int prev = INF;
	cin>>N>>Q>>A>>B;
	A--;B--;
	segment_tree<Int> minus(N), plus(N);
	vector<Int> dp(Q);
	REP(i,Q){
		cin>>x[i];
		x[i]--;
		//update allA, allB
		if(i==0){
			allA = abs(x[i]-A);
			allB = abs(x[i]-B);
		}else{
			Int s0 = allA + abs(B-x[i]), s1 = allB + abs(A-x[i]);
			Int t0 = minus.range(0,x[i]+1)+x[i], t1=plus.range(x[i],N)-x[i];
			Int t = min({s0,s1,t0,t1});
			dp[i] = t;
			Int d = abs(x[i]-x[i-1]);
			minus.add(0,N,d);
			plus.add(0,N,d);
			minus.set(x[i-1],t-x[i-1]);
			plus.set(x[i-1],t+x[i-1]);
			allA += d;
			allB += d;
		}
	}
	Int ans = min(allA,allB), d = 0;
	for(int i=Q-1;i>=1;i--){
		ans = min(ans,dp[i] + d);
		d+=abs(x[i]-x[i-1]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 19712