#include<bits/stdc++.h>
using namespace std;
#define MAXN	400005
#define INF	1e18
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct info {int len; long long num; };
info merge (info a, info b) {
	return (info) {a.len + b.len, min(a.num, a.len + b.num)};
}
struct Segment_Tree {
	int n, root, size;
	long long delta;
	info lv[MAXN], rv[MAXN];
	int lc[MAXN], rc[MAXN];
	void update(int root) {
		lv[root] = merge(lv[rc[root]], lv[lc[root]]);
		rv[root] = merge(rv[lc[root]], rv[rc[root]]);
	}
	void build(int root, int l, int r, int x, int y, int z) {
		if (l == r) {
			if (l == x) lv[root] = rv[root] = (info) {1, abs(z - y)};
			else if (l == y) lv[root] = rv[root] = (info) {1, abs(z - x)};
			else lv[root] = rv[root] = (info) {1, (long long) INF};
			return;
		}
		int mid = (l + r) / 2;
		lc[root] = ++size;
		build(lc[root], l, mid, x, y, z);
		rc[root] = ++size;
		build(rc[root], mid + 1, r, x, y, z);
		update(root);
	}
	void build(int N, int x, int y, int z) {
		n = N;
		root = size = 0;
		build(root, 1, n, x, y, z);
	}
	void add(int x) {
		delta += x;
	}
	void modify(int root, int l, int r, int pos, long long value) {
		if (l == r) {
			lv[root].num = min(lv[root].num, value);
			rv[root].num = min(rv[root].num, value);
			return;
		}
		int mid = (l + r) / 2;
		if (mid >= pos) modify(lc[root], l, mid, pos, value);
		else modify(rc[root], mid + 1, r, pos, value);
		update(root);
	}
	void modify(int pos, long long value) {
		modify(root, 1, n, pos, value - delta);
	}
	info queryl(int root, int l, int r, int ql, int qr) {
		if (l == ql && r == qr) return lv[root];
		info ans = (info) {0, (long long) INF};
		int mid = (l + r) / 2;
		if (mid + 1 <= qr) ans = merge(ans, queryl(rc[root], mid + 1, r, max(mid + 1, ql), qr));
		if (mid >= ql) ans = merge(ans, queryl(lc[root], l, mid, ql, min(mid, qr)));
		return ans;
	}
	info queryr(int root, int l, int r, int ql, int qr) {
		if (l == ql && r == qr) return rv[root];
		info ans = (info) {0, (long long) INF};
		int mid = (l + r) / 2;
		if (mid >= ql) ans = merge(ans, queryr(lc[root], l, mid, ql, min(mid, qr)));
		if (mid + 1 <= qr) ans = merge(ans, queryr(rc[root], mid + 1, r, max(mid + 1, ql), qr));
		return ans;
	}
	info queryl(int l, int r) {
		if (l > r) return (info) {0, (long long) INF};
		else return queryl(root, 1, n, l, r);
	}
	info queryr(int l, int r) {
		if (l > r) return (info) {0, (long long) INF};
		else return queryr(root, 1, n, l, r);
	}
	long long query(int root, int l, int r, int pos) {
		if (l == r) return lv[root].num;
		int mid = (l + r) / 2;
		if (mid >= pos) return query(lc[root], l, mid, pos);
		else return query(rc[root], mid + 1, r, pos);
	}
	long long query(int pos) {
		return query(root, 1, n, pos);
	}
	long long getans(int root, int l, int r) {
		if (l == r) return lv[root].num + delta;
		long long ans = INF;
		int mid = (l + r) / 2;
		ans = min(ans, getans(lc[root], l, mid));
		ans = min(ans, getans(rc[root], mid + 1, r));
		return ans;
	}
	long long getans() {
		return getans(root, 1, n);
	}
} ST;
int a[MAXN];
int main() {
	int n, q, sx, sy;
	read(n), read(q), read(sx), read(sy);
	for (int i = 1; i <= q; i++)
		read(a[i]);
	ST.build(n, sx, sy, a[1]);
	for (int i = 2; i <= q; i++) {
		long long tmp = min(min(ST.queryl(1, a[i] - 1).num, ST.queryr(a[i] + 1, n).num) + 1, ST.query(a[i])) + ST.delta;
		ST.add(abs(a[i] - a[i - 1]));
		ST.modify(a[i - 1], tmp);
	}
	cout << ST.getans() << endl;
	return 0;
}

Measured memory_bytes: 16640