#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;


#include <vector>
using namespace std;


//Base class for Segment Trees
template <class T>
class segtree_base
{
protected:
	size_t width;
	vector<T> vec;
	T def;
	virtual T query_raw(int l_, int r_, int a_, int b_, int k_) = 0;
public:
	segtree_base(size_t size_, T def_ = T()) : def(def_)
	{
		width = 1;
		while (width < size_)width *= 2;
		vec.resize(width * 2 - 1, def);
	}
	//Ask a query in ranges [left,right)
	T query(int left, int right)
	{
		return query_raw(left, right, 0, width, 0);
	}
	//Get the number of child nodes
	size_t treeWidth()
	{
		return width;
	}
	virtual ~segtree_base() {}
};

#include <algorithm>
//Range Minimum Tree
template <class T, class Comp>
class rmq_tree : public segtree_base<T>
{
public:
	rmq_tree(size_t size_) : segtree_base<T>(size_, Comp::defval)
	{}

	//Do [] <= base
	void init(const vector<T>&base)
	{
		for (int i = 0; i < min(this->width, base.size()); i++) this->vec[i + this->width - 1] = base[i];
		for (int i = this->width - 2; i >= 0; i--) this->vec[i] = std::min(this->vec[i * 2 + 1], this->vec[i * 2 + 2], Comp());
	}

	//Make [index] <= val;
	void update(int index, T val)
	{
		auto &vec = this->vec;
		index += (this->width - 1);
		vec[index] = val;
		while (index > 0)
		{
			index = (index - 1) / 2;
			vec[index] = std::min(vec[index * 2 + 1], vec[index * 2 + 2], Comp());
		}
	}
private:
	T query_raw(int l_, int r_, int a_, int b_, int k_)override
	{
		const auto &vec = this->vec;
		if (l_ <= a_ && b_ <= r_)
		{
			return vec[k_];
		}
		if (b_ <= l_ || r_ <= a_)
		{
			return this->def;
		}
		int m = (a_ + b_) / 2;
		return std::min(
			query_raw(l_, r_, a_, m, k_ + k_ + 1),
			query_raw(l_, r_, m, b_, k_ + k_ + 2), Comp());
	}
};

//Functors for Segment Trees
template <class T>
struct my_less : std::less<T>
{
	static constexpr T defval = std::numeric_limits<T>::max() - INT_MAX;
};
template <class T>
struct my_greater : std::greater<T>
{
	static constexpr T defval = std::numeric_limits<T>::min();
};


LL N, Q, A, B;
map<int, LL>x;
vector<LL>coord;
map<LL, int>dict;



int main(void)
{
	cin >> N >> Q >> A >> B;
	coord.push_back(A);
	coord.push_back(B);
	x[-2] = B;
	x[-1] = A;
	for (int i = 0; i < Q; ++i)
	{
		LL xx; cin >> xx;
		x[i] = xx;
		coord.push_back(xx);
	}
	sort(coord.begin(), coord.end());
	coord.erase(unique(coord.begin(), coord.end()), coord.end());
	LL M = coord.size();
	for (int i = 0; i < M; ++i)
	{
		dict[coord[i]] = i;
	}
	rmq_tree<LL, my_less<LL>>inc(M), dec(M);
	for (int i = 0; i < M; ++i)
	{
		inc.update(i, INT_MAX + coord[i]);
		dec.update(i, INT_MAX - coord[i]);
	}
	//初期化式はdp(0,-2) = 0
	int f = dict[x[-2]];
	inc.update(f, +coord[f]);
	dec.update(f, -coord[f]);
	LL base = 0;
	for (int i = 0; i < Q; ++i)
	{
		LL dif = abs(x[i] - x[i - 1]);
		base += dif;
		//x[i]を中心に　右にinc　左にdecを見る
		int center = dict[x[i]];
		LL lef = dec.query(0, center) + coord[center];
		LL rht = inc.query(center, M) - coord[center];
		LL val = min(lef, rht);
		//セグ木のdict[x[i - 1]]番目に新しい値を入れる
		int index = dict[x[i - 1]];
		inc.update(index, val + coord[index] - dif);
		dec.update(index, val - coord[index] - dif);
	}
	LL ans = LLONG_MAX;
	for (int i = 0; i < M; ++i)
	{
		LL segval = inc.query(i, i + 1) - coord[i];
		LL real = segval + base;
		ans = min(ans, real);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 27888