#include<iostream>
#include<algorithm>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;
ll const MAX = 200005;
ll const INF = 100000000000000000;
ll tree[3][MAX * 4];
ll x[MAX];
ll n_;
ll lazy = 0;

void init(ll n) {
	n_ = 1;
	while (n_ <= n) {
		n_ <<= 1;
	}
	REP(i, 1, n_*2) {
		tree[1][i] = tree[2][i] = INF;
	}
}

void update(ll i, ll x, ll n) {
	ll now = n_ + n;
	tree[i][now] = x;
	while (now > 1) {
		now /= 2;
		tree[i][now] = min(tree[i][now * 2], tree[i][now * 2 + 1]);
	}
}

ll query_o(ll i, ll a, ll b, ll k, ll l, ll r) {
	if (a <= l && r <= b) {
		return tree[i][k];
	}
	else if (r <= a || b <= l) {
		return INF;
	}
	else {
		ll ans1 = query_o(i, a, b, k * 2, l, (l + r) / 2);
		ll ans2 = query_o(i, a, b, k * 2 + 1, (l + r) / 2, r);
		return min(ans1, ans2);
	}
}

ll query(ll i, ll a, ll b) {
	return query_o(i, a, b, 1, 0, n_);
}

int main() {
	ll n, q, a, b;
	cin >> n >> q >> a >> b;
	REP(i, 1, q) {
		cin >> x[i];
	}
	x[0] = a;
	init(n);
	update(1, -b, b);
	update(2, b, b);
	REP(i, 0, q-1) {		
		ll t;
		ll s = abs(x[i + 1] - x[i]);
		t = min(query(1, 1, x[i + 1]) + x[i + 1], query(2, x[i + 1], n + 1) - x[i + 1]) + lazy;
		update(1, t - lazy - s - x[i], x[i]);
		update(2, t - lazy - s + x[i], x[i]);
		lazy += s;
	}
	ll ans = INF;
	REP(i, 1, n) {
		ans = min(ans, tree[1][n_ + i] + i);
	}
	cout << ans+lazy << endl;
}