#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

template<typename temp_type> struct segment_tree {
	// Elements count
	int n;
	
	// Values
	temp_type vals[MAXN];
	
	// Tree
	temp_type tt[4 * MAXN];
	temp_type add[4 * MAXN];
	
	// Combine from two values
	temp_type combine(temp_type v1, temp_type v2){
		return min(v1, v2);
	}
	
	// Recursive build
	void build(int ind, int tl, int tr){
		if (tl == tr){
			tt[ind] = vals[tl];
			add[ind] = 0;
			return;
		}
		int tm = (tl + tr) >> 1;
		build(ind << 1, tl, tm);
		build((ind << 1) + 1, tm + 1, tr);
		tt[ind] = combine(tt[ind << 1], tt[(ind << 1) + 1]);
		add[ind] = 0;
	}	
	
	// Recursive get
	temp_type get_val(int ind, int tl, int tr, int l, int r){
		if (tl == l && tr == r){
			return tt[ind];
		}
		int tm = (tl + tr) >> 1;
		temp_type result;
		if (r <= tm){
			result = get_val(ind << 1, tl, tm, l, r);
		} else if (l > tm){
			result = get_val((ind << 1) + 1, tm + 1, tr, l, r);
		} else {
			result = combine(get_val(ind << 1, tl, tm, l, tm), get_val((ind << 1) + 1, tm + 1, tr, tm + 1, r));
		}
		result = result + add[ind];
		return result;
	}	
	
	// Recursive update (set value)
	void upd_val(int ind, int tl, int tr, int l, int r, temp_type add_val){
		if (tl == l && tr == r){
			add[ind] += add_val;
			tt[ind] += add_val;
			return;
		}
		int tm = (tl + tr) >> 1;
		if (r <= tm){
			upd_val(ind << 1, tl, tm, l, r, add_val);
		} else if (l > tm){
			upd_val((ind << 1) + 1, tm + 1, tr, l, r, add_val);
		} else {
			upd_val(ind << 1, tl, tm, l, tm, add_val);
			upd_val((ind << 1) + 1, tm + 1, tr, tm + 1, r, add_val);
		}
		tt[ind] = combine(tt[ind << 1], tt[(ind << 1) + 1]) + add[ind];
	}
	
	// Build (for call)
	void build(){
		build(1, 0, n - 1);
	}
	
	// Get (for call)
	temp_type get_val(int l, int r){
		return get_val(1, 0, n - 1, l, r);
	}
	
	// Recursive update (for call)
	void upd_val(int l, int r, temp_type add_val){
		upd_val(1, 0, n - 1, l, r, add_val);
	}
};

segment_tree<ll> dp_left[2], dp_right[2];

int start[2];

void solve(){
	int n, q;
	scanf("%d%d%d%d", &n, &q, &start[0], &start[1]);
	start[0]--, start[1]--;
	REP(i, 0, 2) {
		dp_left[i].n = n;
		dp_right[i].n = n;
		REP(j, 0, n) {
			dp_left[i].vals[j] = INF;
			dp_right[i].vals[j] = INF;
		}
		dp_left[i].vals[start[i ^ 1]] = n - 1 - start[i ^ 1];
		dp_right[i].vals[start[i ^ 1]] = start[i ^ 1];
		dp_left[i].build();
		dp_right[i].build();
	}
	int last_pos = -1;
	while(q--) {
		int pos;
		scanf("%d", &pos);
		pos--;
		ll l_val[2], r_val[2];
		REP(i, 0, 2) {
			int last = last_pos;
			if (last == -1) {
				last = start[i];
			}
			
			l_val[i] = dp_left[i].get_val(0, pos);
			if (l_val[i] < INF) {
				l_val[i] -= (n - 1 - pos);
			}
			
			dp_left[i].upd_val(0, n - 1, abs(last - pos));
			
			r_val[i] = dp_right[i].get_val(pos, n - 1);
			if (r_val[i] < INF) {
				r_val[i] -= pos;
			}
			
			dp_right[i].upd_val(0, n - 1, abs(last - pos));
		}
		
		REP(i, 0, 2) {
			int last = last_pos;
			if (last == -1) {
				last = start[i ^ 1];
			}
			
			ll new_val = min(l_val[i ^ 1], r_val[i ^ 1]);
			if (new_val < INF) {
				ll old_val = dp_left[i].get_val(last, last);
				if (old_val != INF) {
					ll old_final_val = old_val - (n - 1 - last);
					if (old_final_val > new_val) {
						dp_left[i].upd_val(last, last, new_val - old_final_val);
					}
				} else {
					dp_left[i].upd_val(last, last, new_val + (n - 1 - last));
				}
				
				old_val = dp_right[i].get_val(last, last);
				if (old_val != INF) {
					ll old_final_val = old_val - last;
					if (old_final_val > new_val) {
						dp_right[i].upd_val(last, last, new_val - old_final_val);
					}
				} else {
					dp_right[i].upd_val(last, last, new_val + last);
				}
			}
		}
		
		last_pos = pos;
	}
	
	ll ans = INF;
	REP(i, 0, 2) {
		REP(j, 0, n) {
			ll tmp = dp_right[i].get_val(j, j) - j;
			ans = min(ans, tmp);
		}
	}
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 55552