#include<bits/stdc++.h>
#define FL "a"
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=2e5+10;
const ll INF=1ll<<60;
inline ll read(){
  ll d=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')d=d*10+ch-48,ch=getchar();
  return d*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

int n,q,x[N];
ll mnv[2][N<<2],lz[N<<2],ans=INF;//0:+ 1:-
#define ls (i<<1)
#define rs (i<<1|1)
#define mid ((l+r)>>1)
inline void update(int i){
  mnv[0][i]=min(mnv[0][ls],mnv[0][rs]);mnv[1][i]=min(mnv[1][ls],mnv[1][rs]);
}
inline void cover(int i,ll v){lz[i]+=v;mnv[0][i]+=v;mnv[1][i]+=v;}
inline void pushdown(int i){
  if(lz[i])cover(ls,lz[i]),cover(rs,lz[i]),lz[i]=0;
}
void build(int i,int l,int r){
  mnv[0][i]=mnv[1][i]=INF;if(l==r)return;build(ls,l,mid);build(rs,mid+1,r);
}
inline void insert(int i,int l,int r,int p,ll v){
  if(l==r){mnv[0][i]=min(mnv[0][i],v+p);mnv[1][i]=min(mnv[1][i],v-p);return;}
  pushdown(i);p<=mid?insert(ls,l,mid,p,v):insert(rs,mid+1,r,p,v);update(i);
}
inline ll query(int i,int l,int r,int x,int y,int p){
  if(x<=l&&r<=y)return mnv[p][i];pushdown(i);ll s=INF;
  if(x<=mid)s=query(ls,l,mid,x,y,p);
  if(mid<y)s=min(s,query(rs,mid+1,r,x,y,p));return s;
}

int main()
{
  n=read();q=read();x[0]=read();
  build(1,1,n);insert(1,1,n,read(),0);
  for(int i=1;i<=q;i++)x[i]=read();
  for(int i=1;i<=q;i++){
    ll ql=query(1,1,n,1,x[i],1)+x[i],qr=query(1,1,n,x[i],n,0)-x[i];
    cover(1,abs(x[i]-x[i-1]));insert(1,1,n,x[i-1],min(ql,qr));
  }
  for(int i=1;i<=n;i++)ans=min(ans,query(1,1,n,i,i,0)-i);
  printf("%lld\n",ans);return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll INF = 4e18;

struct STNode {
    typedef STNode* NP;
    NP l, r;
    int sz;
    ll mi;
    STNode(int _sz) : sz(_sz) {
        mi = INF;
        if (sz == 1) return;
        l = new STNode(sz/2);
        r = new STNode(sz-sz/2);
    }
    void set(int k, ll x) {
        if (sz == 1) {
            mi = min(mi, x);
            return;
        }
        if (k < sz/2) {
            l->set(k, x);
        } else {
            r->set(k-sz/2, x);
        }
        mi = min(l->mi, r->mi);
    }
    ll get(int a, int b) {
        if (b <= 0 || sz <= a) return INF;
        if (a <= 0 && sz <= b) return mi;
        return min(l->get(a, b), r->get(a-sz/2, b-sz/2));
    }
};

const int MN = 222222;
int n, q, a, b;
int x[MN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> q >> a >> b;
    x[0] = a;
    for (int i = 1; i <= q; i++) {
        cin >> x[i];
    }
    
    STNode* tr = new STNode(n+1);
    STNode* tr1 = new STNode(n+1);
    STNode* tr2 = new STNode(n+1);
    tr->set(b, 0);
    tr1->set(b, -b);
    tr2->set(b, b);
    
    ll sm = 0;
    for (int i = 0; i < q; i++) {
        ll c = min(tr1->get(1, x[i+1]+1) + sm + x[i+1], tr2->get(x[i+1]+1, n+1) + sm - x[i+1]);
        sm += abs(x[i+1] - x[i]);
        tr->set(x[i], c - sm);
        tr1->set(x[i], c - x[i] - sm);
        tr2->set(x[i], c + x[i] - sm);
    }
    cerr << tr->get(x[0], x[0]+1) + sm << endl;
    cout << tr->get(1, n+1) + sm << endl;
    return 0;
}