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



using namespace std;



template <class T> bool minimize(T &x, const T &y) {

    if (x > y) x = y; else return false; return true;

}



typedef long long ll;



const int N = 2e5 + 10;



int n, m, A, B;

int a[N];

ll s[N], bit1[N], bit2[N], f[N];



void upbit1(int x, ll para) {

    for (; x <= n; x += x & -x)

        minimize(bit1[x], para);

}



ll getbit1(int x) {

    ll ret = (ll)(1e16);

    for (; x; x -= x & -x)

        minimize(ret, bit1[x]);

    return ret;

}



void upbit2(int x, ll para) {

    for (; x; x -= x & -x)

        minimize(bit2[x], para);

}



ll getbit2(int x) {

    ll ret = (ll)(1e16);

    for (; x <= n; x += x & -x)

        minimize(ret, bit2[x]);

    return ret;

}



int main() {

    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> m >> A >> B;

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

        cin >> a[i];

    /// init

    for (int i = 2; i <= m; i++) {

        s[i] = s[i - 1] + (ll)(abs(a[i] - a[i - 1]));

        /// A B

        f[i] = 1ll * abs(B - a[i]) + 1ll * abs(A - a[1]) + s[i - 1];

        /// B A

        f[i] = min(f[i], 1ll * abs(A - a[i]) + 1ll * abs(B - a[1]) + s[i - 1]);

    }

    memset(bit1, 60, sizeof(bit1));

    memset(bit2, 60, sizeof(bit2));

    /// dp

    for (int i = 2; i <= m; i++) {

        /// ai >= aj

        minimize(f[i], getbit1(a[i]) + (ll)(a[i]) + s[i - 1]);

        /// ai < aj

        minimize(f[i], getbit2(a[i] + 1) - (ll)(a[i]) + s[i - 1]);

        /// update

        upbit1(a[i - 1], f[i] - s[i] - (ll)(a[i - 1]));

        upbit2(a[i - 1], f[i] - s[i] + (ll)(a[i - 1]));

    }

    ll res = min(abs(a[1] - A), abs(a[1] - B)) + s[m];

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

        minimize(res, f[i] + s[m] - s[i]);

    cout << res;

}


// Faster C++ solution for the same problem (measured speedup: 4.21946251954895x):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <cmath>

#include <cstring>

#include <map>

#include <set>

#include <vector>

#include <deque>

#include <queue>



#define pb push_back

#define mp make_pair

#define x first

#define y second

#define FOR(i, a, b) for(int i=a, loop=b; i<=loop; ++i)

#define REV(i, a, b) for(int i=a, loop=b; i>=loop; --i)

#define mize(a, b) a = min(a, b)

#define maxi(a, b) a = max(a, b)

#define shl(k) ((k) << 1)

using namespace std;



const int N = 2e5+5;

int n, m, A, B, x[N], idx[N];

int64_t le[N*4], ri[N*4], INF = 1e17;



void build(int k=1, int l=1, int r=n)

{

    if (l == r) {

        idx[r] = k;

        if (r == B) {

            le[k] = -r; ri[k] = r;

        } else le[k] = ri[k] = INF;

    } else {

        int m = (l+r) >> 1;

        build(shl(k), l, m);

        build(shl(k)+1, m+1, r);

        le[k] = min(le[shl(k)], le[shl(k)+1]);

        ri[k] = min(ri[shl(k)], ri[shl(k)+1]);

    }

}

void update(int u, int64_t x, int k=1, int l=1, int r=n)

{

    if (l == r) {

        le[k] = x - r;

        ri[k] = x + r;

    } else {

        int m = (l+r) >> 1;

        if (u<=m) update(u, x, shl(k), l, m);

        else update(u, x, shl(k)+1, m+1, r);



        le[k] = min(le[shl(k)], le[shl(k)+1]);

        ri[k] = min(ri[shl(k)], ri[shl(k)+1]);

    }

}

int64_t get_le(int u, int k=1, int l=1, int r=n)

{

    if (l == r) return le[k];

    int m = (l+r) >> 1;

    if (u <= m) return get_le(u, shl(k), l, m);

    return min(le[shl(k)], get_le(u, shl(k)+1, m+1, r));

}

int64_t get_ri(int u, int k=1, int l=1, int r=n)

{

    if (l == r) return ri[k];

    int m = (l+r) >> 1;

    if (m < u) return get_ri(u, shl(k)+1, m+1, r);

    return min(ri[shl(k)+1], get_ri(u, shl(k), l, m));

}

int main()

{

    ios::sync_with_stdio(); cin.tie(0);



    cin >> n >> m >> A >> B;

    FOR(i, 1, m) cin >> x[i];

    x[0] = A;



    int64_t ans = INF, add = 0, tmp;

    build();

    FOR(i, 0, m-1) {

        tmp = min(x[i+1]+get_le(x[i+1]), get_ri(x[i+1])-x[i+1]) + add;

        add += abs(x[i+1] - x[i]);

        update(x[i], tmp-add);



        ///if (i == 1) cout << tmp <<  endl;

    }



    FOR(i, 1, n) {

        ans = min(ans, le[idx[i]] + i);

    }

    cout << ans + add;

}