#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

using namespace std;
int64_t pow(int64_t a,int64_t b){//a^bを求める
	if(b==0){
		return 1;
	}else{
		int64_t temp = pow(a,b/2);
		temp = temp * temp;
		if(b%2==1){
			temp = temp * a;
		}
		return temp;
	}
}


#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>

class SegmentTree_min {
public:
	SegmentTree_min(int64_t size,const int64_t *d);
	SegmentTree_min(const SegmentTree_min& t);
	SegmentTree_min& operator=(const SegmentTree_min& t);
	int64_t calcmin(const int64_t a,const int64_t b) const;//[a,b]の間の最小値
	void change(const int64_t address,const int64_t value);
	virtual ~SegmentTree_min();
private:
	int64_t max_depth;
	int64_t calcmin(const int64_t a,const int64_t b,const int64_t ptr,const int64_t range_min,const int64_t range_max) const;
	//calcminからよばれる内部処理 [a,b]について、配列番号ptrのものを探索 配列番号ptrが指す範囲は、[range_min,range_max]
	int64_t size;
	int64_t *data;
};
SegmentTree_min::SegmentTree_min(int64_t dsize,const int64_t *d) {

	// TODO 自動生成されたコンストラクター・スタブ
	for(int i=63;i>=0;i--){
		if(dsize&((uint64_t)1<<i)){
			max_depth = i+1;
			break;
		}
	}
	this->size = ((uint64_t)1<<(max_depth));
	data = new int64_t[2*size-1];
	for(int64_t i=0;i<dsize;i++){
		data[size-1+i]=d[i];
	}
	for(int64_t i=dsize;i<size;i++){
		data[size-1+i]=std::numeric_limits<int64_t>::max();
	}
	for(int64_t i=size-2;i>=0;i--){
		data[i]=std::min(data[2*i+1],data[2*i+2]);
	}
}
SegmentTree_min::SegmentTree_min(const SegmentTree_min& t){
	if(&t==this){
		max_depth = 1;
		size = 1;
		data = new int64_t[1];
		data[0]=0;
	}else{
		max_depth = t.max_depth;
		size = t.size;
		data = new int64_t[2*size-1];
		for(int64_t i=0;i<(2*size-1);i++){
			data[i]=t.data[i];
		}
	}
}
SegmentTree_min& SegmentTree_min::operator=(const SegmentTree_min& t){
	if(&t!=this){
		delete[] data;
		max_depth = t.max_depth;
		size = t.size;
		data = new int64_t[2*size-1];
		for(int64_t i=0;i<(2*size-1);i++){
			data[i]=t.data[i];
		}
	}
	return *this;
}
int64_t SegmentTree_min::calcmin(const int64_t a,const int64_t b) const{
	return calcmin(a,b,0,0,size-1);
}
int64_t SegmentTree_min::calcmin(const int64_t a,const int64_t b,const int64_t ptr,const int64_t range_min,const int64_t range_max) const{
	if(a<=range_min&&b>=range_max){
		return data[ptr];
	}else{
		int64_t border = (range_max+range_min-1)/2;
		if(b<=border){
			return calcmin(a,b,2*ptr+1,range_min,border);
		}else if(a>=border+1){
			return calcmin(a,b,2*ptr+2,border+1,range_max);
		}else{
			return std::min(calcmin(a,border,ptr*2+1,range_min,border),calcmin(border+1,b,ptr*2+2,border+1,range_max));
		}
	}
}
void SegmentTree_min::change(const int64_t address,const int64_t value){
	data[address + size -1]=value;
	int64_t i=address+size-1;
	do{
		i=(i-1)/2;
		data[i]=std::min(data[2*i+1],data[2*i+2]);
	}while(i!=0);
}
SegmentTree_min::~SegmentTree_min() {
	// TODO Auto-generated destructor stub
	delete[] data;
}
SegmentTree_min **X;
SegmentTree_min **Y;
int64_t N,Z,W;
int64_t *a;
int64_t calcX(int64_t i,int64_t yindex){
	if(i==N-1){
		int64_t temp;
		if(yindex==N){
			temp=labs(a[i]-W);
		}else{
			temp=labs(a[i]-a[yindex]);
		}
		temp=-temp;
		X[yindex]->change(i,temp);
		return temp;
	}
	if(X[yindex]->calcmin(i,i)>100000000000){
		int64_t temp=-1*Y[i]->calcmin(i+1,N-1);
		X[yindex]->change(i,temp);
		return temp;
	}else{
		return X[yindex]->calcmin(i,i);
	}

}
int64_t calcY(int64_t i,int64_t xindex){
	if(i==N-1){
		int64_t temp;
		if(xindex==N){
			temp=labs(a[i]-Z);
		}else{
			temp=labs(a[i]-a[xindex]);
		}
		Y[xindex]->change(i,temp);
		return temp;
	}
	if(Y[xindex]->calcmin(i,i)>100000000000){
		int64_t temp=-1*X[i]->calcmin(i+1,N-1);
		Y[xindex]->change(i,temp);
		return temp;
	}else{
		return Y[xindex]->calcmin(i,i);
	}
}
int main() {
	cin>>N>>Z>>W;
	a=new int64_t[N];
	for(int32_t i1=0;i1<N;i1++){
		cin>>a[i1];
	}
	int64_t *temp=new int64_t[N];
	for(int32_t i1=0;i1<N;i1++){
		temp[i1]=100000000200;
	}
	X=new SegmentTree_min*[N+1];
	Y=new SegmentTree_min*[N+1];
	for(int32_t i1=0;i1<N+1;i1++){
		X[i1]=new SegmentTree_min(N,temp);
		Y[i1]=new SegmentTree_min(N,temp);

	}

	for(int64_t i1=N-1;i1>=0;i1--){
		for(int64_t ai=0;ai<N+1;ai++){
			calcX(i1,ai);
			calcY(i1,ai);
			//cout<<"i1="<<i1<<"ai="<<ai<<"calcX="<<calcX(i1,ai)<<endl;;
			//cout<<"i1="<<i1<<"ai="<<ai<<"calcY="<<calcY(i1,ai)<<endl;;

		}
	}
	cout<<-1*X[N]->calcmin(0,N-1)<<endl;






}

Measured memory_bytes: 130304