// Slower C++ solution:
#include <bits/stdc++.h>

 

#define MAXN (1 << 18)

#define ll long long

 

int n, q, A, B;

int x[MAXN];

ll seg1[MAXN << 1], seg2[MAXN << 1];

 

ll query(ll *seg, int u, int l, int r, int ql, int qr){

	if(ql <= l && r <= qr) return seg[u];

	int m = l + r >> 1, ls = u << 1, rs = ls | 1;

	ll ret = LLONG_MAX;

	if(!(m < ql)) ret = std::min(ret, query(seg, ls, l, m, ql, qr));

	if(!(qr < m + 1)) ret = std::min(ret, query(seg, rs, m + 1, r, ql, qr));

	return ret;

}

 

void insert(ll *seg, int u, int l, int r, int pos, ll val){

	if(l == r){

		seg[u] = val;

		return;

	}

	int m = l + r >> 1, ls = u << 1, rs = ls | 1;

	if(pos <= m) insert(seg, ls, l, m, pos, val);

	else insert(seg, rs, m + 1, r, pos, val);

	seg[u] = std::min(seg[ls], seg[rs]);

}

 

int main(){

	scanf("%d%d%d%d", &n, &q, &A, &B);

	memset(seg1, 0x7f, sizeof seg1);

	memset(seg2, 0x7f, sizeof seg2);

	x[0] = B;

	insert(seg1, 1, 1, n, A, A);

	insert(seg2, 1, 1, n, A, -A);

	ll delta = 0;

	for(int i = 1; i <= q; ++ i){

		scanf("%d", x + i);

		

		ll tmp1 = query(seg1, 1, 1, n, x[i] + 1, n) - x[i];

		ll tmp2 = query(seg2, 1, 1, n, 1, x[i]) + x[i];

		tmp1 = std::min(tmp1, tmp2);

		

//		ll now = query(seg1, 1, 1, n, x[i - 1], x[i - 1]) - x[i - 1] + delta;

//		if(tmp1 < now){

			insert(seg1, 1, 1, n, x[i - 1], tmp1 + x[i - 1] - std::abs(x[i] - x[i - 1]));

			insert(seg2, 1, 1, n, x[i - 1], tmp1 - x[i - 1] - std::abs(x[i] - x[i - 1]));

//		}

		

		delta += std::abs(x[i] - x[i - 1]);

	}

	ll ans = LLONG_MAX;

	for(int i = 1; i <= n; ++ i){

		ans = std::min(ans, query(seg1, 1, 1, n, i, i) - i + delta);

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 9.58502542497506x):
#include <bits/stdc++.h>



using namespace std;



const int MaxN = 200005;

const long long oo = 1e18;



struct SegmentTree

{

    long long Min[4 * MaxN][3], Lazy[4 * MaxN];

    int Low[4 * MaxN], High[4 * MaxN];

    void InitTree(int x, int L, int R)

    {

        Low[x] = L;

        High[x] = R;

        Lazy[x] = 0;

        Min[x][0] = Min[x][1] = Min[x][2] = oo;

        if (L == R)

        {

            return;

        }

        int Mid = (L + R) / 2;

        InitTree(x * 2, L, Mid);

        InitTree(x * 2 + 1, Mid + 1, R);

    

    }

    void doLazy(int x)

    {

        if (Low[x] != High[x])

        {

            Lazy[x * 2] += Lazy[x];

            Lazy[x * 2 + 1] += Lazy[x];

        }

        for (int i = 0; i < 3; i++)

        {

            Min[x][i] += Lazy[x];

        }

        Lazy[x] = 0;

    }

    void Update(int x, int pos, long long Val)

    {

        doLazy(x);

        if (Low[x] > pos || pos > High[x])

            {return;}

        if (Low[x] == High[x])

        {

            if (Min[x][0] > Val)

            {

                Min[x][0] = Val;

                Min[x][1] = Val - Low[x];

                Min[x][2] = Val + Low[x];

            }

            return;

        }

        Update(x * 2, pos, Val);

        Update(x * 2 + 1, pos, Val);

        for (int i = 0; i < 3; i++)

        {    Min[x][i] = min(Min[x * 2][i], Min[x * 2 + 1][i]);

    }}

    long long Get(int x, int L, int R, int type)

    {

        doLazy(x);

        if (Low[x] > R || High[x] < L)

        {

            return oo;

        }

        if (Low[x] >= L && High[x] <= R)

        {

            return Min[x][type];

        }

        return min(Get(x * 2, L, R, type), Get(x * 2 + 1, L, R, type));

    }

};



int n, q, A, B;

int a[MaxN];

SegmentTree ST;



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    cin >> n >> q >> A >> B;

    for (int i = 1; i <= q; i++)

    {

        cin >> a[i];

    }

    ST.InitTree(1, 1, n);

    ST.Update(1, B, abs(A - a[1]));

    ST.Update(1, A, abs(B - a[1]));

    for (int i = 2; i <= q; i++)

    {

        long long Min = min(ST.Get(1, 1, a[i], 1) + a[i], ST.Get(1, a[i], n, 2) - a[i]);

        ST.Lazy[1] += abs(a[i - 1] - a[i]);

        ST.doLazy(1);

        ST.Update(1, a[i - 1], Min);

    }

    cout << ST.Min[1][0];

    return 0;

}