#pragma GCC "-O3"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>

 
 
using namespace std;
 
 
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
/** Interface */
 
inline int readChar();
template <class T = int> inline T readInt(); 
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x ); 
inline void writeWord( const char *s );
 
/** Read */
 
static const int buf_size = 4096;
 
inline int getChar() {
    static char buf[buf_size];
    static int len = 0, pos = 0;
    if (pos == len)
        pos = 0, len = fread(buf, 1, buf_size, stdin);
    if (pos == len)
        return -1;
    return buf[pos++];
}
 
inline int readChar() {
    int c = getChar();
    while (c <= 32)
        c = getChar();
    return c;
}
 
template <class T>
inline T readInt() {
    int s = 1, c = readChar();
    T x = 0;
    if (c == '-')
        s = -1, c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return s == 1 ? x : -x;
}
 
/** Write */
 
static int write_pos = 0;
static char write_buf[buf_size];
 
inline void writeChar( int x ) {
    if (write_pos == buf_size)
        fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
    write_buf[write_pos++] = x;
}
 
template <class T> 
inline void writeInt( T x, char end ) {
    if (x < 0)
        writeChar('-'), x = -x;
 
    char s[24];
    int n = 0;
    while (x || !n)
        s[n++] = '0' + x % 10, x /= 10;
    while (n--)
        writeChar(s[n]);
    if (end)
        writeChar(end);
}
 
inline void writeWord( const char *s ) {
    while (*s)
        writeChar(*s++);
}
 
struct flusher {
    ~flusher() {
        if (write_pos)
            fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
    }
} flusher;
 
 
#define hash hash228 
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define next next1
const int MAXN = 200001;


int n;
int ss;
long long dp[MAXN][2];
long long sum[MAXN][2];
int where[MAXN];
long long d[3][2][4 * MAXN];
long long mod[3][2][4 * MAXN];



void push(int g, int t, int v) {
    if (mod[g][t][v]) {
        d[g][t][v] += mod[g][t][v];
        if (v < ss) {
            mod[g][t][v << 1] += mod[g][t][v];
            mod[g][t][(v << 1) + 1] += mod[g][t][v];
        }
        mod[g][t][v] = 0;
    }
}


void change(int g, int t, int i, long long x) {
    vector<int> hah;
    hah.push_back(i);
    while (i >> 1 > 0) {
        i >>= 1;
        hah.push_back(i);
    }
    reverse(all(hah));
    for (auto xx: hah) {
        push(g, t, xx);
        if (xx < ss) {
            push(g, t, xx << 1);
            push(g, t, (xx << 1) + 1);
        }
    }
    d[g][t][hah.back()] = x;
    for (int it = sz(hah) - 2; it >= 0; it--) {
        d[g][t][hah[it]] = min(d[g][t][hah[it] << 1], d[g][t][(hah[it] << 1) + 1]);
    }
}


int l, r;


long long rmq(int g, int t, int v, int vl, int vr) {
    if (vl > r || vr < l || r < l) {
        return (long long)1e18;
    }
    if (l <= vl && vr <= r) {
        push(g, t, v);
        return d[g][t][v];
    }
    push(g, t, v);
    int vn = v << 1;
    int vm = (vl + vr) >> 1;
    return min(rmq(g, t, vn, vl, vm), rmq(g, t, vn + 1, vm + 1, vr));
}


int x[MAXN];


int main() {
    int a, b;
    a = readInt(), n = readInt(), a = readInt(), b = readInt();
    for (int i = 0; i < n; i++) {
        x[i] = readInt();
    }
    if (n == 1) {
        cout << min(abs(x[0] - a), abs(x[0] - b)) << endl;
        return 0;
    }
    if (n == 2) {
        long long t = abs(x[1] - a) + abs(x[0] - b);
        chkmin(t, abs(x[1] - b) + abs(x[0] - a));
        chkmin(t, abs(x[0] - a) + abs(x[0] - x[1]));
        chkmin(t, abs(x[0] - b) + abs(x[0] - x[1]));
        cout << t << endl;
        return 0;
    }
    ss = 1;
    while (ss < n) {
        ss <<= 1;
    }
    vector<pair<int, int> > v;
    for (int i = 0; i < n; i++) {
        v.push_back(make_pair(x[i], i));
    }
    sort(all(v));
    for (int i = 0; i < n; i++) {
        where[v[i].second] = i;
    }
    for (int g = 0; g < 3; g++) {
        for (int i = 0; i < 2 * ss; i++) {
            for (int j = 0; j < 2; j++) {
                d[g][j][i] = (long long)1e18;
            }
        }
    }
    sum[0][0] = abs(x[0] - a);
    sum[0][1] = abs(x[0] - b);
    for (int i = 1; i < n; i++) {
        sum[i][0] += sum[i - 1][0];
        sum[i][0] += abs(x[i] - x[i - 1]);
        sum[i][1] += sum[i - 1][1];
        sum[i][1] += abs(x[i] - x[i - 1]);
    }
    long long ans = (long long)1e18;
    dp[0][0] = abs(x[0] - a) + abs(x[1] - b);
    dp[0][1] = abs(x[0] - b) + abs(x[1] - a);
    for (int j = 0; j < 2; j++) {
        change(0, j, ss + where[0], dp[0][j]);
        change(1, j, ss + where[0], dp[0][j] + x[0]);
        change(2, j, ss + where[0], dp[0][j] - x[0]);
    }
    chkmin(ans, dp[0][0] + sum[n - 1][0] - sum[1][0]);
    chkmin(ans, dp[0][1] + sum[n - 1][1] - sum[1][1]);
    for (int i = 1; i < n; i++) {
        dp[i][0] = sum[i][0] + (i == n - 1 ? 0: abs(x[i + 1] - b));
        dp[i][1] = sum[i][1] + (i == n - 1 ? 0: abs(x[i + 1] - a));
        if (i != 1) {
            for (int j = 0; j < 2; j++) {
                chkmin(dp[i][j], dp[i - 1][j ^ 1] + (i != n - 1 ? abs(x[i + 1] - x[i - 1]): 0));
                long long res = 0;
                if (i == n - 1) {
                    l = 1, r = i - 1;
                    res = rmq(0, j ^ 1, 1, 1, ss);
                } else {
                    l = where[i + 1] + 1, r = n;
                    res = rmq(1, j ^ 1, 1, 1, ss) - x[i + 1];
                    l = 1, r = where[i + 1] + 1;
                    chkmin(res, rmq(2, j ^ 1, 1, 1, ss) + x[i + 1]);
                }
                chkmin(dp[i][j], res);
            }
        } else {
            chkmin(dp[i][0], 1LL * abs(x[0] - a) + abs(x[1] - b) + abs(x[2] - x[0]));
            chkmin(dp[i][1], 1LL * abs(x[0] - b) + abs(x[1] - a) + abs(x[2] - x[0]));
        }
        if (i != n - 1) {
            for (int k = 0; k < 3; k++) {
                for (int j = 0; j < 2; j++) {
                    mod[k][j][1] += abs(x[i + 1] - x[i]);
                }
            }
        }
        for (int j = 0; j < 2; j++) {
            ans = min(ans, dp[i][j] + (i != n - 1 ? sum[n - 1][j] - sum[i + 1][j]: 0LL));
            change(0, j, ss + where[i], dp[i][j]);
            change(1, j, ss + where[i], dp[i][j] + x[i]);
            change(2, j, ss + where[i], dp[i][j] - x[i]);
        } 
    }
    ans = min(ans, sum[n - 1][0]);
    ans = min(ans, sum[n - 1][1]);
    cout << ans << '\n';
    return 0;   
}


Measured memory_bytes: 82544