Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000000)

N,X,Y=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

memo={}
def func(n,last,turn):  #n:カードの残り枚数、last:前の手番が最後に引いたスコア、turn: 0先手の番 1後手の番
    #print "func(",n,",",last,",",turn,")"
    if (n,last,turn) in memo:
        return memo[(n,turn)]
    if n==1:
        ret=abs(last-A[N-n])
    elif turn==0:
        ret=max( func(n-1,last,0) , func(n-1,A[N-n],1) ) #手番がXのまま  手番がYに移動
    elif turn==1:
        ret=min( func(n-1,last,1) , func(n-1,A[N-n],0) ) #手番がYのまま  手番がXに移動
    memo[(n,turn)]=ret
    return ret


print func(N,Y,0)

Fixed submission:
N,Z,W=map(int,raw_input().split())
a=[]
a=map(int,raw_input().split())

if len(a)!=1:
	print max ( abs(a[-1]-W), abs(a[-2]-a[-1]) )
else:
	print abs(a[0]-W)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000000)

N,X,Y=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

memo={}
def func(n,last,turn):  #n:カードの残り枚数、last:前の手番が最後に引いたスコア、turn: 0先手の番 1後手の番
    #print "func(",n,",",last,",",turn,")"
    if (n,last,turn) in memo:
        return memo[(n,last,turn)]
    if n==1:
        ret=abs(last-A[N-n])
    elif turn==0:
        ret=max( func(n-1,last,0) , func(n-1,A[N-n],1) ) #手番がXのまま  手番がYに移動
    elif turn==1:
        ret=min( func(n-1,last,1) , func(n-1,A[N-n],0) ) #手番がYのまま  手番がXに移動
    memo[(n,last,turn)]=ret
    return ret


print func(N,Y,0)

Fixed submission:
N,Z,W=map(int,raw_input().split())
a=[]
a=map(int,raw_input().split())

if len(a)!=1:
	print max ( abs(a[-1]-W), abs(a[-2]-a[-1]) )
else:
	print abs(a[0]-W)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000000)

N,X,Y=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

memo={}
def func(n,last,turn):  #n:カードの残り枚数、last:前の手番が最後に引いたスコア、turn: 0先手の番 1後手の番
    #print "func(",n,",",last,",",turn,")"
    if (n,last,turn) in memo:
        return memo[(n,last,turn)]
    if n==1:
        ret=abs(last-A[N-n])
    elif turn==0:
        ret=max( func(n-1,last,0) , func(n-1,A[N-n],1) ) #手番がXのまま  手番がYに移動
    elif turn==1:
        ret=min ( func(n-1,last,1) , func(n-1,A[N-n],0) ) #手番がYのまま  手番がXに移動
    memo[(n,last,turn)]=ret
    return ret


print func(N,Y,0)

Fixed submission:
N,Z,W=map(int,raw_input().split())
a=[]
a=map(int,raw_input().split())

if len(a)!=1:
	print max ( abs(a[-1]-W), abs(a[-2]-a[-1]) )
else:
	print abs(a[0]-W)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000000)

N,X,Y=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

def func(n,last,turn):  #n:カードの残り枚数、last:前の手番が最後に引いたスコア、turn: 0先手の番 1後手の番
    #print "func(",n,",",last,",",turn,")"
    if n==1:
        return abs(last-A[N-n])
    elif turn==0:
        return max( func(n-1,last,0) , func(n-1,A[N-n],1) ) #手番がXのまま  手番がYに移動
    elif turn==1:
        return min ( func(n-1,last,1) , func(n-1,A[N-n],0) ) #手番がYのまま  手番がXに移動


print func(N,Y,0)

Fixed submission:
N,Z,W=map(int,raw_input().split())
a=[]
a=map(int,raw_input().split())

if len(a)!=1:
	print max ( abs(a[-1]-W), abs(a[-2]-a[-1]) )
else:
	print abs(a[0]-W)