#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF=1e12;

vector<LL> pos;

struct ans{
	LL val,lef,rig;
	void build(){
		val=INF;
		lef=INF;
		rig=INF;
	}
	void update(LL x){
		val=min(INF,val+x);
		lef=min(INF,lef+x);
		rig=min(INF,rig+x);
	}
	void swaps(LL x,LL y){
		val=min(val,y);
		lef=val-x;
		rig=val+x;
	}
}kosong;

ans merge(ans a,ans b){
	ans hasil;
	hasil.val=min(a.val,b.val);
	hasil.lef=min(a.lef,b.lef);
	hasil.rig=min(a.rig,b.rig);
	return hasil;
}

struct segment{
	LL L,R,lazy;
	ans ret;
	segment *ki,*ka;
	void build(LL x,LL y){
		L=x;
		R=y;
		lazy=0;
		ret.build();
		if(L==R)return;
		LL mid=(L+R)/2;
		ki=new segment;
		ki->build(x,mid);
		ka=new segment;
		ka->build(mid+1,y);
		ret=merge(ki->ret,ka->ret);
		return;
	}
	void balance(){
		if(!lazy)return;
		ki->ret.update(lazy);
		ki->lazy+=lazy;
		ka->ret.update(lazy);
		ka->lazy+=lazy;
		lazy=0;
	}
	void update(LL x,LL y){
		if(L==R){
			ret.swaps(x,y);
			return;
		}
		balance();
		LL mid=(L+R)/2;
		if(x<=mid)ki->update(x,y);
		else ka->update(x,y);
		ret=merge(ki->ret,ka->ret);
	}
	ans query(LL x,LL y){
		if(L>=x && R<=y)return ret;
		if(L>y || R<x)return kosong;
		balance();
		return merge(ki->query(x,y),ka->query(x,y));
	}
}data;

LL minimum_time(int N, int Q, int A, int B, vector<int> X) {
	kosong.build();
	data.build(1,N);
	pos.push_back(A);
	pos.push_back(B);
	for(auto isi : X)pos.push_back(isi);
	data.update(pos[0],0);
	for(LL i=1;i<=Q;i++){
		LL temp=min(data.query(1,pos[i+1]).lef+pos[i+1],data.query(pos[i+1],N).rig-pos[i+1]);
		data.lazy+=abs(pos[i+1]-pos[i]);
		data.ret.update(abs(pos[i+1]-pos[i]));
		data.update(pos[i],temp);
	}
	return data.query(1,N).val;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int N,Q,A,B,no;
	vector<int> V;
	cin >> N >> Q >> A >> B;
	for(int i=1;i<=Q;i++){
		cin >> no;
		V.push_back(no);
	}
	cout << minimum_time(N,Q,A,B,V) << '\n';
	return 0;
}