#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

struct Segtree{
  vl mv;
  ll al;
  int size;
  Segtree(int n){
    size = 1;
    while(size < n){
      size *= 2;
    }
    mv = vl(size*2, INFLL);
  }
  void update(int p, ll x){
    p += size - 1;
    mv[p] = x - al;
    while(p > 0){
      p = (p - 1) / 2;
      mv[p] = min(mv[p*2+1], mv[p*2+2]);
    }
  }
  ll query(int a, int b, int k, int l, int r){
    if(a <= l && r <= b){
      return mv[k] + al;
    } else if(b <= l || r <= a){
      return INFLL;
    } else {
      ll chl = query(a, b, k*2+1, l, (l+r)/2);
      ll chr = query(a, b, k*2+2, (l+r)/2, r);
      return min(chl, chr);
    }
  }
  ll query(int a, int b){
    return query(a, b, 0, 0, size);
  }
  ll add_all(ll x){
    al += x;
  }
};

int n, q;

ll a, b;
ll x[200010];

void print(Segtree &seg1){
  REP(i, n){
    ll res = seg1.query(i, i+1) - i;
    if(res >= 1000){
      cout << "INF ";
    } else {
      cout << res << " ";
    }
  }
  cout << endl;
}

int main(){

  n = in();
  q = in();
  a = in() - 1;
  b = in() - 1;
  REP( i , q ){
    x[i] = in() - 1;
  }

  Segtree seg1(n);
  Segtree seg2(n);
  
  // print(seg1);

  ll dpa = abs(x[0] - b);
  ll dpb = abs(x[0] - a);
  seg1.update(a, dpa + a);
  seg1.update(b, dpb + b);
  seg2.update(a, dpa - a);
  seg2.update(b, dpb - b);

  // print(seg1);
  // return 0;
  
  FOR(i, 1, q){
    ll left = seg2.query(0, x[i]) + x[i];
    ll right = seg1.query(x[i], n) - x[i];
    ll dpx = min(left, right);
    seg1.add_all(abs(x[i] - x[i-1]));
    seg2.add_all(abs(x[i] - x[i-1]));
    ll dpx_old = seg1.query(x[i-1], x[i-1]+1) - x[i-1];
    if(dpx < dpx_old){
      seg1.update(x[i-1], dpx + x[i-1]);
      seg2.update(x[i-1], dpx - x[i-1]);
    }
    // print(seg1);    
  }

  ll ans = INFLL;
  REP(i, n){
    ll res = seg1.query(i, i+1) - i;
    chmin(ans, res);
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 9984