#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
typedef long long LL;
const LL INF = 1LL << 62;
const int maxN = 2e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m, A, B;
LL p[maxN], sum[maxN];
struct rec {
	LL x, y; int i;
	inline bool operator < (const rec &v) const {
		return x < v.x;
	}
};
namespace Set {
	set<rec> S;
	typedef set<rec>::iterator Sit;
	int T;

	LL eval(const rec &d, LL p) {
		return d.y + abs(p - d.x) + sum[T] - sum[d.i];
	}

	LL get(LL p) {
		Sit it = S.lower_bound((rec){p});
		LL res = it == S.end() ? INF : eval(*it, p);
		if (it != S.begin()) res = min(res, eval(*(--it), p));
		return res;
	}

	void ins(const rec &d) {
		if (get(d.x) <= d.y) return;
		for (Sit it = S.lower_bound(d); it != S.end() && eval(d, it->x) <= eval(*it, it->x); it = S.lower_bound(d)) S.erase(it);
		while (1) {
			Sit it = S.lower_bound(d);
			if (it == S.begin()) break;
			-- it;
			if (eval(d, it->x) <= eval(*it, it->x)) S.erase(it);
			else break;
		}
		S.insert(d);
	}
}

int main() {

	n = ri(), m = ri(), A = ri(), B = ri();
	p[0] = A, sum[0] = 0, Set::T = 0;
	Set::ins((rec){B, 0, 0});
	
	rep (i, 1, m) {
		p[i] = ri();
		sum[i] = sum[i-1] + abs(p[i] - p[i-1]);
		LL tp = Set::get(p[i]);
		++ Set::T;
		Set::ins((rec){p[i-1] ,tp, i});

//		rep (i, 1, n) printf("%lld%c", Set::get(i), " \n"[i == n]);
	}
	
	LL res = INF;
	rep (i, 1, n) res = min(res, Set::get(i));
	printf("%lld\n", res);
	
	return 0;
}
