//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 1LL<<60
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 2e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes"); exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No"); exit(0); }
void one() { puts("-1"); exit(0); }

ll seq[maxn];

struct Segtree
{
	struct Node
	{
		ll val, add;
	};
	Node tree[maxn * 4];
	void modify_add_Node(int node, ll val)
	{
		tree[node].val += val;
		tree[node].add += val;
	}
	void pushup(int node)
	{
		tree[node].val = min(tree[node << 1].val, tree[node << 1 | 1].val);
	}
	void pushdown(int node)
	{
		if (tree[node].add)
		{
			modify_add_Node(node << 1, tree[node].add);
			modify_add_Node(node << 1 | 1, tree[node].add);
			tree[node].add = 0;
		}
	}
	void build(int l, int r, int node)
	{
		if (l == r)
		{
			tree[node].val = seq[l];
			tree[node].add = 0;
			return;
		}
		int mid = (l + r) >> 1;
		build(l, mid, node << 1);
		build(mid + 1, r, node << 1 | 1);
		pushup(node);
	}
	void modify_add(int L, int R, int l, int r, int node, int val)
	{
		if (r < L || R < l) return;
		if (L <= l&&r <= R)
		{
			modify_add_Node(node, val);
			return;
		}
		pushdown(node);
		int mid = (l + r) >> 1;
		modify_add(L, R, l, mid, node << 1, val);
		modify_add(L, R, mid + 1, r, node << 1 | 1, val);
		pushup(node);
	}
	void modify_min(int pos, int l, int r, int node, ll val)
	{
		if (l == r)
		{
			tree[node].val = min(tree[node].val, val);
			return;
		}
		pushdown(node);
		int mid = (l + r) >> 1;
		if (pos <= mid) modify_min(pos, l, mid, node << 1, val);
		else modify_min(pos, mid + 1, r, node << 1 | 1, val);
		pushup(node);
	}
	ll query_min(int L, int R, int l, int r, int node)
	{
		if (r<L || R<l) return INF;
		if (L <= l&&r <= R) return tree[node].val;
		pushdown(node);
		int mid = (l + r) >> 1;
		return min(query_min(L, R, l, mid, node << 1), query_min(L, R, mid + 1, r, node << 1 | 1));
	}
	ll dfs(int l, int r, int node)
	{
		if (l == r) return tree[node].val + l;
		pushdown(node);
		int mid = (l + r) >> 1;
		return min(dfs(l, mid, node << 1), dfs(mid + 1, r, node << 1 | 1));
	}
}s,t;

int N, Q, A, B;
int x[maxn];

void solve()
{
	sa(N), sa(Q), sa(A), sa(B);
	repp(i, 1, Q)
	{
		sa(x[i]);
	}
	repp(i, 1, N)
	{
		seq[i] = INF;
	}
	seq[B] = -B;
	s.build(1, N, 1);

	seq[B] = B;
	t.build(1, N, 1);

	x[0] = A;
	repp(i, 1, Q)
	{
		ll tmp = min(s.query_min(1, x[i], 1, N, 1) + x[i], t.query_min(x[i], N, 1, N, 1) - x[i]);

		s.modify_add(1, N, 1, N, 1, abs(x[i] - x[i - 1]));
		t.modify_add(1, N, 1, N, 1, abs(x[i] - x[i - 1]));

		s.modify_min(x[i - 1], 1, N, 1, tmp - x[i - 1]);
		t.modify_min(x[i - 1], 1, N, 1, tmp + x[i - 1]);
	}
	ll ans = s.dfs(1, N, 1);

	printf("%lld\n", ans);
}


int main()
{
	solve();
	//system("pause");
	return 0;
}

Measured memory_bytes: 23552