#include <bits/stdc++.h>

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"
#include "profile.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 600001;
const ll MOD = 1e9 + 7;
using cd = complex<double>;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

struct seg_tree {
    seg_tree(int n) : sz(n), data(4 * n), to_add(4 * n) {

    }

    void add_(int v, int tl, int tr, ll val) {
        if (tl >= r || l >= tr) {
            return;
        }
        if (tl >= l && tr <= r) {
            to_add[v] += val;
            data[v] += val;
            return;
        }
        push(v);
        int tm = (tl + tr) >> 1;
        add_(v << 1, tl, tm, val);
        add_(v << 1 | 1, tm, tr, val);
        data[v] = min(data[v << 1], data[v << 1 | 1]);
    }

    void add(int l_, int r_, ll val) {
        l = l_;
        r = r_;
        add_(1, 0, sz, val);
    }

    ll get_(int v, int tl, int tr) {
        if (tl >= r || l >= tr) {
            return INF;
        }
        if (tl >= l && tr <= r) {
            return data[v];
        }
        push(v);
        int tm = (tl + tr) >> 1;
        return min(get_(v << 1, tl, tm), get_(v << 1 | 1, tm, tr));
    }

    ll get_min(int l_, int r_) {
        l = l_;
        r = r_;
        return get_(1, 0, sz);
    }

    void push(int v) {
        if (to_add[v]) {
            for (int i:{v << 1, v << 1 | 1}) {
                to_add[i] += to_add[v];
                data[i] += to_add[v];
            }
            to_add[v] = 0;
        }
    }

    const ll INF = 1e18;
    int sz;
    int l, r;
    vector<ll> data;
    vector<ll> to_add;
};

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    profile("all");
    auto solve = [](int _) {
        int n;
        cin >> n;
        int q;
        cin >> q;
        int a;
        cin >> a;
        int b;
        cin >> b;

        seg_tree minus(n + 1);
        seg_tree plus(n + 1);
        for (int i = 1; i <= n; ++i) {
            minus.add(i, i + 1, -i);
            plus.add(i, i + 1, i);
        }
        minus.add(1, n + 1, 1e15);
        plus.add(1, n + 1, 1e15);
        minus.add(b, b + 1, -1e15);
        plus.add(b, b + 1, -1e15);
        int last_x = a;
        for (int i = 1; i <= q; ++i) {
            int cur_x;
            cin >> cur_x;
            ll clever_dp = min(cur_x + minus.get_min(1, cur_x + 1), -cur_x + plus.get_min(cur_x + 1, n + 1));
            minus.add(1, n + 1, abs(last_x - cur_x));
            plus.add(1, n + 1, abs(last_x - cur_x));
            minus.add(last_x, last_x + 1, clever_dp - last_x - minus.get_min(last_x, last_x + 1));
            plus.add(last_x, last_x + 1, clever_dp + last_x - plus.get_min(last_x, last_x + 1));
            last_x = cur_x;
        }
        ll ans = minus.INF;
        for (int i = 1; i <= n; ++i) {
            ans = min(plus.get_min(i, i + 1) - i, ans);
        }
        cout<<ans;
    };


    fast_io();
    cout.precision(9);
    cout << fixed;

    solve(1);


}


Measured memory_bytes: 25216