#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const LL INF = LLONG_MAX / 2;

const int MAXN = (int) 2e5;

int n, m, A, B;

int x[MAXN + 5];

inline void input()
{
	n = read<int>(), m = read<int>(), A = read<int>(), B = read<int>();
	for(int i = 1; i <= m; ++i) x[i] = read<int>();
}

const int MAX_NODE = MAXN * 4;

struct SEGT
{
	LL mn[MAX_NODE + 5];
	LL add[MAX_NODE + 5];

	inline void build(int u, int l, int r)
	{
		mn[u] = INF;
		add[u] = 0;
		if(l == r) return;

		int mid = (l + r) / 2;
		build(u << 1, l, mid);
		build(u << 1 | 1, mid + 1, r);
	}

	inline void push_up(int u) { mn[u] = min(mn[u << 1], mn[u << 1 | 1]); }
	inline void push_down(int u)
	{
		if(add[u])
		{
			mn[u << 1] += add[u];
			mn[u << 1 | 1] += add[u];
			add[u << 1] += add[u];
			add[u << 1 | 1] += add[u];
			add[u] = 0;
		}
	}

	inline void upd_add(int u, int l, int r, int ql, int qr, LL val)
	{
		if(ql > qr) return;
		if(ql <= l && r <= qr)
		{
			mn[u] += val;
			add[u] += val;
			return;
		}
		push_down(u);

		int mid = (l + r) / 2;
		if(ql <= mid) upd_add(u << 1, l, mid, ql, qr, val);
		if(mid < qr) upd_add(u << 1 | 1, mid + 1, r, ql, qr, val);
		push_up(u);
	}

	inline void upd_pos(int u, int l, int r, int pos, LL val)
	{
		if(l == r)
		{
			chkmin(mn[u], val);
			return;
		}
		push_down(u);

		int mid = (l + r) / 2;
		if(pos <= mid) upd_pos(u << 1, l, mid, pos, val);
		else upd_pos(u << 1 | 1, mid + 1, r, pos, val);
		push_up(u);
	}

	inline LL query(int u, int l, int r, int ql, int qr)
	{
		if(ql > qr) return INF;
		if(ql <= l && r <= qr) return mn[u];
		push_down(u);

		int mid = (l + r) / 2;
		LL res = INF;
		if(ql <= mid) chkmin(res, query(u << 1, l, mid, ql, qr));
		if(mid < qr) chkmin(res, query(u << 1 | 1, mid + 1, r, ql, qr));
		return res;
	}
};

inline void solve()
{
	static SEGT dp, f, g;

	dp.build(1, 1, n);
	f.build(1, 1, n);
	g.build(1, 1, n);

	x[0] = A;
	dp.upd_pos(1, 1, n, B, 0);
	f.upd_pos(1, 1, n, B, 0 + B);
	g.upd_pos(1, 1, n, B, 0 - B);

	for(int i = 1; i <= m; ++i)
	{
		LL res = min(g.query(1, 1, n, 1, x[i]) + x[i], f.query(1, 1, n, x[i] + 1, n) - x[i]);

		dp.upd_add(1, 1, n, 1, n, abs(x[i] - x[i - 1]));
		f.upd_add(1, 1, n, 1, n, abs(x[i] - x[i - 1]));
		g.upd_add(1, 1, n, 1, n, abs(x[i] - x[i - 1]));

		dp.upd_pos(1, 1, n, x[i - 1], res);
		f.upd_pos(1, 1, n, x[i - 1], res + x[i - 1]);
		g.upd_pos(1, 1, n, x[i - 1], res - x[ i - 1]);
	}

	printf("%lld\n", dp.query(1, 1, n, 1, n));
}

int main()
{
#ifndef ONLINE_JUDGE
//	freopen("F.in", "r", stdin);
//	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 37120