#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 1LL << 61;
const int max_size = 262144;
int N, Q, A, B, x[200009]; long long seg[2][524296];
void release(int tp, int pos, long long val) {
	pos += max_size;
	seg[tp][pos] = min(seg[tp][pos], val);
	while (pos > 1) {
		pos >>= 1;
		seg[tp][pos] = min(seg[tp][pos * 2], seg[tp][pos * 2 + 1]);
	}
}
long long min_query(int tp, int a, int b, int k = 1, int l = 0, int r = max_size) {
	if (a <= l && r <= b) return seg[tp][k];
	if (r <= a || b <= l) return inf;
	long long lc = min_query(tp, a, b, k * 2, l, (l + r) >> 1);
	long long rc = min_query(tp, a, b, k * 2 + 1, (l + r) >> 1, r);
	return min(lc, rc);
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N >> Q >> A >> B; A--, B--;
	for (int i = 1; i <= Q; i++) cin >> x[i], x[i]--;
	long long ret = inf;
	for (int tp = 0; tp < 2; tp++) {
		fill(seg[0], seg[0] + max_size * 2, inf);
		fill(seg[1], seg[1] + max_size * 2, inf);
		release(0, A, -A);
		release(1, A, A);
		x[0] = B;
		long long ans = inf;
		for (int i = 1; i <= Q; i++) {
			long long lc = min_query(0, 0, x[i]) + x[i];
			long long rc = min_query(1, x[i], N) - x[i];
			long long res = min(lc, rc) - abs(x[i] - x[i - 1]);
			release(0, x[i - 1], res - x[i - 1]);
			release(1, x[i - 1], res + x[i - 1]);
		}
		for (int i = 0; i < N; i++) ans = min(ans, min_query(0, i, i + 1) + i);
		for (int i = 1; i <= Q; i++) ans += abs(x[i] - x[i - 1]);
		ret = min(ret, ans);
		swap(A, B);
	}
	cout << ret << endl;
	return 0;
}