void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.math;

  int n, x, y; rd(n, x, y);
  auto a=readln.split.to!(int[]);

  auto b=new int[](n);
  foreach(i, e; a) b[i]=(e-a[$-1]).abs;
  int cur=1;
  for(size_t i=0; i<n; i++){
    if(i==n-1){
      if(cur) writeln((a[i]-y).abs);
      else writeln((a[i]-x).abs);
      return;
    }
    auto s=a[$-1];
    if(cur){
      s=(s-y).abs;
      auto gr=reduce!((r, e)=>r&&(e>s))(true, b[i..($-1)]);
      if(!gr){writeln(s); return;}
      for(auto j=i; j<n-1; j++){
        if(b[i]<b[j]) i=j;
      }
      x=a[i];
    }else{
      s=(s-x).abs;
      auto ls=reduce!((r, e)=>r&&(e<s))(true, b[i..($-1)]);
      if(!ls){writeln(s); return;}
      for(auto j=i; j<n-1; j++){
        if(b[i]>b[j]) i=j;
      }
      y=a[i];
    }
    cur^=1;
  }

  assert(false);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}