#include<bits/stdc++.h>
using namespace std;
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define MC(n,m) memcpy((n),(m),sizeof(n))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define IOS do { ios_base::sync_with_stdio(0);cin.tie(0); } while (0)
#define SZ(x) ((int)(x).size())
#ifndef OFFLINE
    #define ONLINE_JUDGE
#endif
#ifdef ONLINE_JUDGE
#define FILEIO(name) \
    do { \
        freopen(name".in", "r", stdin); \
        freopen(name".out", "w", stdout); \
    } while (0)
#else
    #define FILEIO(name) do { } while(0)
#endif

#define _TOKEN_CAT2(x, y) x ## y
#define _TOKEN_CAT(x, y) _TOKEN_CAT2(x, y)
#define _MACRO_OVERL3(_1, _2, _3, _N, ...) _N
#define _RANGE1(a) int _TOKEN_CAT(_t, __LINE__)=0; _TOKEN_CAT(_t, __LINE__)<(a); (_TOKEN_CAT(_t, __LINE__))++
#define _RANGE2(i, a) int (i)=0; (i)<(a); (i)++
#define _RANGE3(i, a, b) int (i)=(a); (i)!=(b); (i)+=((b)>(a)?1:-1)
#define loop(...) for (_MACRO_OVERL3(__VA_ARGS__, _RANGE3, _RANGE2, _RANGE1)(__VA_ARGS__))

#ifdef OFFLINE
template<typename T>
void _dump(const char* s, T&& head) { 
    cerr << s << " = " << head << " <<" << endl; 
}

template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail) {
    int c = 0;
    while (*s!=',' || c!=0) {
        if (*s=='(' || *s=='[' || *s=='{' || *s=='<') c++;
        if (*s==')' || *s==']' || *s=='}' || *s=='>') c--;
        cerr << *s++;
    }
    cerr << " = " << head << ", ";
    _dump(s+1, tail...);
}

#define dump(...) do { \
    cerr << "\033[32m>> " << __LINE__ << ": " << __PRETTY_FUNCTION__ << endl; \
    cout << "   "; \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
    cout << "\033[0m"; \
} while (0)
#else
#define dump(...) 
#endif

#define au auto
template<class T>
using vec = vector<T>;

template<typename Iter>
ostream& _IterOutput_(ostream &o, Iter b, Iter e, const string ss="", const string se="") {
    o << ss;
    for (auto it=b; it!=e; it++) o << (it==b ? "" : ", ") << *it;
    return o << se;
}

template<typename T1, typename T2>
ostream& operator << (ostream &o, const pair<T1, T2> &pair) {
    return o << "(" << pair.F << ", " << pair.S << ")";
}

template<typename T>
ostream& operator << (ostream &o, const vector<T> &vec) {
    return _IterOutput_(o, ALL(vec), "[", "]");
}

template<typename T>
ostream& operator << (ostream &o, const set<T> &st) {
    return _IterOutput_(o, ALL(st), "{", "}");
}

template<typename T, size_t N>
ostream& operator << (ostream &o, const array<T, N> &arr) {
    return _IterOutput_(o, ALL(arr), "|", "|");
}

template<typename T1, typename T2>
ostream& operator << (ostream &o, const map<T1, T2> &mp) {
    o << "{";
    for (auto it=mp.begin(); it!=mp.end(); it++) {
        o << (it==mp.begin()?"":", ") << it->F << ":" << it->S;
    }
    o << "}";
    return o;
}

void lucky_test() {
    std::random_device rd;
    std::mt19937 gen_(rd());
    std::normal_distribution<double> dist_(0.0, 1.0);

    if (dist_(gen_) >= 4.44444444) {
        cout << "Not lucky" << endl;
        exit(0);
    }
}

#define int long long
const int MX = 222222;
int N, Q, A, B;
int X[MX];
int D[MX];
int dp[2][MX];

int XA[MX], XB[MX];

const int INF = 1e12;
struct Tree {
    int val[MX*3];
    int _val[MX*3];
    int N;

    void _init(int id, int l, int r) {
        val[id] = INF;
        if (r == l+1) return;

        int md = (l+r)/2;
        _init(id*2, l, md);
        _init(id*2+1, md, r);
    }

    void init(int n) {
        N = n+5;
        _init(1, 0, N);
        fill(_val, _val+N, INF);
    }

    void _set(int id, int nl, int nr, int p, int v) {
        if (nl == nr-1) {
            val[id] = min(val[id], v);
            return;
        }

        int md = (nl+nr)/2;
        if (p < md) {
            _set(id*2, nl, md, p, v);
        } else {
            _set(id*2+1, md, nr, p, v);
        }

        val[id] = min(val[id*2], val[id*2+1]);
    }

    void set(int i, int v) {
        _val[i] = min(_val[i], v);

        _set(1, 0, N, i, v);
    }

    int _qry(int id, int nl, int nr, int ql, int qr) {
        if (qr <= nl) return INF;
        if (ql >= nr) return INF;
        if (ql <= nl and nr <= qr) {
            return val[id];
        }

        int md = (nl+nr)/2;
        int ans = min(_qry(id*2, nl, md, ql, qr), _qry(id*2+1, md, nr, ql, qr));
        //cout << id << ' ' << nl << ' ' << nr << ' ' << ans << endl;
        return ans;
    }

    int qry(int ql, int qr) {
        int ans = _qry(1, 0, N, ql, qr+1);

        return ans;
    }
} tree[4];

int32_t main() {
    IOS;

    cin >> N >> Q >> A >> B;

    for (int i=1; i<=Q; i++) {
        cin >> X[i];
    }

    for (int i=2; i<=Q; i++) {
        D[i] = D[i-1] + abs(X[i] - X[i-1]);
    }

    for (int i=1; i<=Q; i++) {
        XA[i] = i == 1 ? B : X[i-1];
        XB[i] = i == 1 ? A : X[i-1];
    }

    for (int i=0; i<4; i++) tree[i].init(N);

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

        int p[4] = {};
        int v[4] = {};
        for (int j=0; j<=1; j++) {
            int &res = dp[j][i];
            //res = INF;
            if (i > 1) {
                res = abs(X[i] - (j ? B : A)) + D[i-1] - D[1] + abs(X[1] - (j ? A : B));
            } else {
                res = abs((j ? B : A) - X[1]);
            }

            auto &mtr = tree[(!j)*2+0], &Mtr = tree[(!j)*2+1];
            int q = mtr.qry(0, X[i]);
            res = min(res, q + D[i-1] + X[i]);

            //cout << "Q1 = " << q << endl;

            q = Mtr.qry(X[i], N);
            res = min(res, q + D[i-1] - X[i]);

            //cout << i << ' ' << j << " = " << res << endl;
            auto *Y = j ? XB : XA;
            p[j*2+0] = Y[i];
            v[j*2+0] = res - D[i] - Y[i];
            p[j*2+1] = Y[i];
            v[j*2+1] = res - D[i] + Y[i];
        }

        for (int j=0; j<4; j++) {
            tree[j].set(p[j], v[j]);
            //if (j >= 2) cout << "Set " << p[j] << " = " << v[j] << endl;
        }
    }

    int ans = INF;
    for (int i=1; i<=Q; i++) {
        ans = min(ans, dp[0][i] + D[Q] - D[i]);
        ans = min(ans, dp[1][i] + D[Q] - D[i]);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 44032