import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    immutable long INF = 1L << 58;

    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto Q = s[1];
    auto A = s[2];
    auto B = s[3];
    auto X = B ~ readln.split.map!(to!int).array;

    auto AM = new LazySegmentTree!(long, INF, 0L)(N+1);
    auto AP = new LazySegmentTree!(long, INF, 0L)(N+1);
    auto BM = new LazySegmentTree!(long, INF, 0L)(N+1);
    auto BP = new LazySegmentTree!(long, INF, 0L)(N+1);

    AM.add(B, B, -INF-B);
    AP.add(B, B, -INF+B);
    BM.add(A, A, -INF-A);
    BP.add(A, A, -INF+A);

    foreach (i; 1..Q+1) {
        long move_ab = min(AM.getVal(0, X[i]) + X[i], AP.getVal(X[i], N) - X[i]);
        long move_ba = min(BM.getVal(0, X[i]) + X[i], BP.getVal(X[i], N) - X[i]);
        AM.add(0, N, abs(X[i] - X[i-1]));
        AP.add(0, N, abs(X[i] - X[i-1]));
        BM.add(0, N, abs(X[i] - X[i-1]));
        BP.add(0, N, abs(X[i] - X[i-1]));
        long am = AM.getVal(X[i-1], X[i-1]);
        long ap = AP.getVal(X[i-1], X[i-1]);
        long bm = BM.getVal(X[i-1], X[i-1]);
        long bp = BP.getVal(X[i-1], X[i-1]);
        long av = min(am + X[i-1], ap - X[i-1], move_ba);
        long bv = min(bm + X[i-1], bp - X[i-1], move_ab);
        AM.add(X[i-1], X[i-1], -am + av - X[i-1]);
        AP.add(X[i-1], X[i-1], -ap + av + X[i-1]);
        BM.add(X[i-1], X[i-1], -bm + bv - X[i-1]);
        BP.add(X[i-1], X[i-1], -bp + bv + X[i-1]);
    }
    long ans = INF;
    foreach (i; 0..N+1) ans = min(ans, AM.getVal(i, i) + i);
    foreach (i; 0..N+1) ans = min(ans, AP.getVal(i, i) - i);
    foreach (i; 0..N+1) ans = min(ans, BM.getVal(i, i) + i);
    foreach (i; 0..N+1) ans = min(ans, BP.getVal(i, i) - i);
    ans.writeln;
}



class LazySegmentTree(T, T e, T le) {
    T[] table;
    T[] lazy_;
    int size;

    this(int n) {
        assert(bsr(n) < 29);
        size = 1 << (bsr(n) + 2);
        table = new T[](size);
        lazy_ = new T[](size);
        fill(table, e);
        fill(lazy_, le);
    }

    void eval(int i, int l, int r) {
        if (lazy_[i] == le) return;

        table[i] += lazy_[i];
        if (l != r) {
            lazy_[i*2+1] += lazy_[i];
            lazy_[i*2+2] += lazy_[i];
        }

        lazy_[i] = le;
    }

    void add(int a, int b, T num) {
        add(a, b, num, 0, 0, size/2-1);
    }

    void add(int a, int b, T num, int i, int l, int r) {
        eval(i, l, r);

        if (a > r || b < l) return;
        if (a <= l && r <= b) {
            lazy_[i] += num;
            eval(i, l, r);
        } else {
            add(a, b, num, i*2+1, l, (l+r)/2);
            add(a, b, num, i*2+2, (l+r)/2+1, r);
            table[i] = min(table[i*2+1], table[i*2+2]);
        }
    }

    T getVal(int a, int b) {
        return getVal(a, b, 0, 0, size/2-1);
    }

    T getVal(int a, int b, int i, int l, int r) {
        eval(i, l, r);

        if (a > r || b < l) return e*10;
        if (a <= l && r <= b) return table[i];
        return
            min(getVal(a, b, i*2+1, l, (l+r)/2),
                getVal(a, b, i*2+2, (l+r)/2+1, r));
    }
}
