#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 400005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int64 val[2],lz;
    int L,R;
}tr[MAXN * 4];
int N,Q,A,B,x[MAXN];
void addlz(int u,int64 v) {
    tr[u].lz += v;
    for(int i = 0 ; i < 2 ; ++i) tr[u].val[i] += v;
}
void pushdown(int u) {
    if(tr[u].lz) {
        addlz(u << 1,tr[u].lz);
        addlz(u << 1 | 1,tr[u].lz);
        tr[u].lz = 0;
    }
}
void update(int u) {
    for(int i = 0 ; i < 2 ; ++i)
        tr[u].val[i] = min(tr[u << 1].val[i],tr[u << 1 | 1].val[i]);
}
void build(int u,int l,int r) {
    tr[u].L = l;tr[u].R = r;
    if(l == r) {
        tr[u].val[0] = 1e16 - l;
        tr[u].val[1] = 1e16 + l;
        return;
    }
    int mid = (l + r) >> 1;
    build(u << 1,l,mid);
    build(u << 1 | 1,mid + 1,r);
    update(u);
}
void Change_pos(int u,int p,int64 v) {
    if(tr[u].L == tr[u].R) {
        tr[u].val[0] = v - tr[u].L;
        tr[u].val[1] = v + tr[u].L;
        return;
    }
    pushdown(u);
    int mid = (tr[u].L + tr[u].R) >> 1;
    if(p <= mid) Change_pos(u << 1,p,v);
    else Change_pos(u << 1 | 1,p,v);
    update(u);
}
void Add_Range(int u,int l,int r,int64 v) {
    if(l > r) return;
    if(tr[u].L == l && tr[u].R == r) {
        addlz(u,v);return;
    }
    pushdown(u);
    int mid = (tr[u].L + tr[u].R) >> 1;
    if(r <= mid) Add_Range(u << 1,l,r,v);
    else if(l > mid) Add_Range(u << 1 | 1,l,r,v);
    else {Add_Range(u << 1,l,mid,v);Add_Range(u << 1 | 1,mid + 1,r,v);}
    update(u);
}
int64 Query(int u,int l,int r,int id) {
    if(l > r) return 1e16;
    if(tr[u].L == l && tr[u].R == r) return tr[u].val[id];
    pushdown(u);
    int mid = (tr[u].L + tr[u].R) >> 1;
    if(r <= mid) return Query(u << 1,l,r,id);
    else if(l > mid) return Query(u << 1 | 1,l,r,id);
    else {return min(Query(u << 1,l,mid,id),Query(u << 1 | 1,mid + 1,r,id));}
}
int64 Getans(int u) {

    if(tr[u].L == tr[u].R) return tr[u].val[0] + tr[u].L;
    pushdown(u);
    return min(Getans(u << 1),Getans(u << 1 | 1));
}
void Solve() {
    read(N);read(Q);read(A);read(B);
    build(1,1,N);
    x[0] = A;
    Change_pos(1,B,0);
    for(int i = 1 ; i <= Q ; ++i) {
        read(x[i]);
        int64 trans = 1e18;
        trans = min(x[i] + Query(1,1,x[i],0),trans);
        trans = min(Query(1,x[i] + 1,N,1) - x[i],trans);
        Change_pos(1,x[i - 1],trans);
        Add_Range(1,1,x[i - 1] - 1,abs(x[i] - x[i - 1]));
        Add_Range(1,x[i - 1] + 1,N,abs(x[i] - x[i - 1]));
    }
    out(Getans(1));enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 17920