/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Majk
 */

#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
constexpr int MOD = 1000000007;

typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned int ui;

template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;

struct input {
	std::istream &cin;
	explicit input(std::istream &cin) :cin(cin){}
	template <typename T> operator T() { T t; cin >> t; return t; }
};
#define $ input{cin}

int logceil(ll x) {int b=0;while(x){x>>=1;++b;}return b;}

namespace std {
    template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector<vector<T>>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector<vector<T>>>(a,vector<vector<T>>(b,vector<T>(c,t))){}};

// #include "../l/mod.h"


#include <cstddef>



template<typename T> struct Fenwick {
	explicit Fenwick(size_t N, T t=T()):F(N,t),N(N),t(t){}
	explicit Fenwick(const vector<T>&A, T t=T()):F(A),N(A.size()),t(t){
		for(int i=0;i<N;i++){int j=i+lsb(i+1);if(j<N)F[j]+=F[i];}}
	void add(int i, T v){while(i<=N){F[i]+=v;i+=lsb(i+1);}}
	T sum(int i)const{T sum(t);while(i){sum+=F[i-1];i-=lsb(i);}return sum;}
	T range(int i,int j)const{T s(t);while(j>i){s+=F[j-1];j-=lsb(j);}while(i>j){s-=F[i-1];i-=lsb(i);}return s;}
	T get(int i)const{return range(i,i+1);}
	constexpr int lsb(int i)const{return i&-i;}
	vector<T> F;size_t N;T t;
};

template<typename F>struct NoCombine {
    const int NOCOMB=-2;
    void setup(size_t){}void op(F&p,F n,size_t,size_t,size_t){p=n;}F up(F l,F r,size_t){return l==r?l:NOCOMB;}
    void down(F&u,F&l,F&r,size_t,size_t,size_t){if(u!=NOCOMB){l=r=u;}u=NOCOMB;}};
template<typename F,typename Op>struct Persistent{Op o;void setup(size_t){}void op(F&p,F n,size_t,size_t, size_t){p=n;}F up(F l, F r, size_t){return o(l,r);}void down(F&,F&,F&,size_t,size_t, size_t b) {}};

template<typename F,typename SetOp,typename CombineOp,typename PowerOp>struct LazyProp{
    void setup(size_t s){this->s=s;L=new F[s]();}
    void down(F&u,F&l,F&r,size_t i,size_t a,size_t b){op(l,L[i],2*i,a,(a+b)/2);op(r,L[i],2*i+1,(a+b)/2,b);L[i]=0;}
    void op(F&p,F n,size_t i,size_t a,size_t b){p=sop(p,pop(n,b-a));if(i<this->s)this->L[i]=sop(this->L[i],n);}
    F up(F l,F r,size_t){return cop(l,r);}SetOp sop;CombineOp cop;PowerOp pop;F*L;size_t s;
};

template <typename F> struct AddOp { F operator()(F a, F b) { return a+b; }};
template <typename F> struct MultOp { F operator()(F a, F b) { return a*b; }};
template <typename F> struct IdempOp { F operator()(F a, F b) { return a; }};
template <typename F> struct MinOp { F operator()(F a, F b) { return std::min(a,b); }};
template <typename F> struct MaxOp { F operator()(F a, F b) { return std::max(a,b); }};

template <typename F, typename Combine> struct SegTree {
	void setup(size_t s, F def) {
		size = 1<<logceil(s);
		T = vector<F>(2*size, def);
		for (size_t i = size-1; i > 0; i--) T[i] = op.up(T[2*i],T[2*i+1], i);
		op.setup(2*size);
	}

	void setup(vector<F> & data, F def = F()) {
		size = 1<<logceil(data.size());
		T = vector<F>(2*size, def);
		copy(data.begin(), data.end(), T.begin() + size);
		for (size_t i = size-1; i > 0; i--) T[i] = op.up(T[2*i],T[2*i+1], i);
		op.setup(2*size);
	}

	inline void put(size_t x, F n) { put(x, x, n); }
	inline void put(size_t from, size_t to, F n) { put2(from, to+1, n, 1, 0, size); }
	inline F get(size_t x) { return get(x, x); }
	inline F get(size_t from, size_t to) { return get2(from, to+1, 1, 0, size); }

	void put2(size_t from, size_t to, F n, size_t i, size_t a, size_t b) {
		if (from <= a && to >= b) { op.op(T[i], n, i, a, b); return; }
		if (from >= b || to <= a) { return; }
		op.down(T[i], T[2*i], T[2*i+1], i, a, b);
		put2(from, to, n, 2*i, a, (a+b)/2);
		put2(from, to, n, 2*i+1, (a+b)/2, b);
		T[i] = op.up(T[2*i], T[2*i+1], i);
	}

	F get2(size_t from, size_t to, size_t i, size_t a, size_t b) {
		if (from <= a && to >= b) { return T[i]; }
		op.down(T[i], T[2*i], T[2*i+1], i, a, b);
		if (to <= (a+b)/2) { return get2(from, to, 2*i, a, (a+b)/2); }
		else if (from >= (a+b)/2) { return get2(from, to, 2*i+1, (a+b)/2, b); }
		else return op.up(get2(from, to, 2*i, a, (a+b)/2), get2(from, to, 2*i+1, (a+b)/2, b), i);
	}

	size_t size;
	vector<F> T;
	Combine op;
};

template<typename T> using SetGetTree = SegTree<T, NoCombine<T>>;
template<typename T> using AddSumTree = SegTree<T, LazyProp<T, AddOp<T>, AddOp<T>, MultOp<T>>>;
template<typename T> using AddMaxTree = SegTree<T, LazyProp<T, AddOp<T>, MaxOp<T>, IdempOp<T>>>;
template<typename T> using AddMinTree = SegTree<T, LazyProp<T, AddOp<T>, MinOp<T>, IdempOp<T>>>;
template<typename T> using SetMinTree = SegTree<T, Persistent<T, MinOp<T>>>;
template<typename T> using SetMaxTree = SegTree<T, Persistent<T, MaxOp<T>>>;


class F {
public:
    void solve(istream& cin, ostream& cout) {
		int N, Q, A, B;
		cin >> N >> Q >> A >> B;
		vector<int> X(Q);
		cin >> X;

		AddMinTree<ll> L, R, C;
		ll INF = 1e18;
		vector<ll> V(N, INF);
		V[A-1] = abs(X[0]-B);
		V[B-1] = abs(X[0]-A);
		C.setup(V);
		for (int i = 0; i < N; ++i) {
			V[i] += i+1;
		}
		L.setup(V);
		for (int i = 0; i < N; ++i) {
			V[i] += -2*(i+1);
		}
		R.setup(V);

//
//		for (int j = 0; j < N; ++j) {
//			cerr << C.get(j) << ' ';
//		} cerr << endl;
//
//		for (int i = 0; i < N; ++i) {
//			ll c = C.get(i), l = L.get(i), r = R.get(i);
//			if (c < INF && (l != c + i + 1 || r != c - i - 1)) cerr << i << ' ' << c << ' ' << l << ' ' << r << endl;
//		}

		for (int i = 1; i < Q; ++i) {
			ll left = R.get(0, X[i]-1) + X[i];
			ll right = L.get(X[i]-1, N-1) - X[i];
			ll best = min(right, left);
//			cerr << left << ' ' << right << ' ' << best << endl;

			L.put(0, N-1, abs(X[i]-X[i-1]));
			R.put(0, N-1, abs(X[i]-X[i-1]));
			C.put(0, N-1, abs(X[i]-X[i-1]));

			ll val = C.get(X[i-1]-1);
			if (val > best) {
				C.put(X[i-1]-1, -val + best);
				L.put(X[i-1]-1, -val + best);
				R.put(X[i-1]-1, -val + best);
			}

//			for (int j = 0; j < N; ++j) {
//				cerr << C.get(j) << ' ';
//			} cerr << endl;

//			for (int j = 0; j < N; ++j) {
//				ll c = C.get(j), l = L.get(j), r = R.get(j);
//				if (c < INF && (l != c + j + 1 || r != c - j - 1)) cerr << i << ' ' << j << ' ' << c << ' ' << l << ' ' << r << endl;
//			}
		}

		cout << C.get(0, N-1) << endl;

//
//		unordered_map<pii, ll> R;
//		R[{min(A, B), max(A, B)}] = (ll) N * Q;
//		for (int i = 0; i < Q; ++i) {
//			unordered_map<pii, ll> S;
//			for (auto it = R.begin(); it != R.end(); ++it) {
//				if (X[i] <= it->x.x) S[{X[i], it->x.y}] = max(S[{X[i], it->x.y}], it->y - it->x.x + X[i]);
//				else if (X[i] >= it->x.y) S[{it->x.x, X[i]}] = max(S[{it->x.x, X[i]}], it->y - X[i] + it->x.y);
//				else {
//					S[{X[i], it->x.y}] = max(S[{X[i], it->x.y}], it->y - X[i] + it->x.x);
//					S[{it->x.x, X[i]}] = max(S[{it->x.x, X[i]}], it->y - it->x.y + X[i]);
//				}
//			}
//
//			swap(R, S);
//		}
//
//		ll ans = 0;
//		for (auto it = R.begin(); it != R.end(); ++it) {
//			ans = max(ans, it->y);
//		}
//		cout << (ll)N*Q - ans << endl;
	}
};


int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	F solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}



Measured memory_bytes: 27264