Problem:
 Score : 500 points    Problem Statement We have a deck consisting of N cards. Each card has an integer written on it. The integer on the i -th card from the top is a_i .  Two people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action:   Draw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn.   The game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand.  X will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?      Constraints  All input values are integers.  1 \leq N \leq 2000  1 \leq Z, W, a_i \leq 10^9         Input Input is given from Standard Input in the following format:  N  Z  W  a_1  a_2  ...  a_N       Output Print the score.        Sample Input 1 3 100 100
10 1000 100      Sample Output 1 900  If X draws two cards first, Y will draw the last card, and the score will be |1000 - 100| = 900 .       Sample Input 2 3 100 1000
10 100 100      Sample Output 2 900  If X draws all the cards first, the score will be |1000 - 100| = 900 .       Sample Input 3 5 1 1
1 1 1 1 1      Sample Output 3 0       Sample Input 4 1 1 1
1000000000      Sample Output 4 999999999

Solution (Python):
def main():
    N, Z, W = map(int, input().split())
    a = list(map(int, input().split()))
    dp = [0] * (N + 1)
    for i in range(N):
        dp[i + 1] = max(abs(a[i] - W), abs(a[i - 1] - a[i]))
    print(dp[-1])


main()

Solution (Python):
def main():
    N, Z, W = map(int, input().split())
    a = list(map(int, input().split()))
    print(max(abs(W - a[N - 1]), abs(a[N - 2] - a[N - 1])))


main()

Solution (Python):
N, Z, W = list(map(int, input().split()))
a = list(map(int, input().split()))

ma = abs(a[-1] - W)
if N != 1:
  ma = max(ma, abs(a[-1] - a[-2]))
print(ma)

Solution (Python):
n,z,w=map(int,input().split())
a=[w]+list(map(int,input().split()))
print(max(abs(w-a[-1]),abs(a[-1]-a[-2])))

Solution (Python):
N,Z,W = list(map(int,input().split(" ")))
nums = list(map(int,input().split(" ")))
c1 = abs(nums[-1]-W)
c2 = -100
if len(nums) > 1:
    c2 = abs(nums[-1]-nums[-2])
print(max(c1,c2))

Solution (Python):
N,Z,W=map(int,input().split())
a=list(map(int,input().split()))
if N==1:
    print(abs(a[0]-W))
else:
    print(max(abs(a[-1]-W),abs(a[-1]-a[-2])))

Solution (Python):
N,Z,W=map(int,input().split())
a=list(map(int,input().split()))
INF=10**19
dp=[[0]*2 for i in range(N+1)]
for i in range(N-1,-1,-1):
    dp[i][0]=-INF
    if i: Y=a[i-1]
    else: Y=W
    dp[i][0]=max(dp[i][0],abs(Y-a[N-1]))
    for j in range(i+1,N): dp[i][0]=max(dp[i][0],dp[j][1])

    dp[i][1]=INF
    if i: X=a[i-1]
    else: X=Z
    dp[i][1]=min(dp[i][1],abs(X-a[N-1]))
    for j in range(i+1,N): dp[i][1]=min(dp[i][1],dp[j][0])
print(dp[0][0])

Solution (Python):
N,Z,W=map(int, input().split())
INL = list(map(int,input().split()))

if N == 1:
    print(abs(INL[0]-W))
else:
    print(max(abs(W-INL[-1]), abs(INL[-2]-INL[-1])))

Solution (Python):


from collections import* 
from fractions import gcd
from functools import* 
from itertools import* 
from operator import mul
from bisect import* 
from heapq import* 
from math import factorial
from copy import deepcopy
import sys

sys.setrecursionlimit(10**6)

def main():
    
    n,z,w,*a=map(int,open(0).read().split())
    if n==1:
        print(abs(a[n-1]-w))
    else:
        print(max(abs(a[n-1]-w),abs(a[n-2]-a[n-1])))

if __name__ == '__main__':
    main()

Solution (Python):
import sys

from fractions import gcd





from itertools import accumulate













input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())



def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  
    Z = int(next(tokens))  
    W = int(next(tokens))  
    a = [ int(next(tokens)) for _ in range(N) ]  

    
    
    if N == 1:
        print(abs(a[-1]-W))
    elif abs(a[-1] - W) > abs(a[-1] - a[-2]):
        print(abs(a[-1] - W))
    else:
        print(abs(a[-1] - a[-2]))

Solution (Python):



















import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N, _, W = MI()
    A = LI()

    if N == 1:
        print(abs(W-A[-1]))
    else:
        
        print(max(abs(W-A[-1]), abs(A[-1]-A[-2]) ))
        
if __name__ == '__main__':
    main()

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, Z: int, W: int, a: "List[int]"):
    if N == 1:
        print(abs(a[0]-W))
    else:
        print(max(abs(a[-1]-a[-2]), abs(a[-1]-W)))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    Z = int(next(tokens))  
    W = int(next(tokens))  
    a = [int(next(tokens)) for _ in range(N)]  
    solve(N, Z, W, a)


if __name__ == '__main__':
    main()

Solution (Python):
"""
n=1の時、山札とＹの初期手札が答え
n>=2の時、
・Ｘは得点の最大化を狙う
・Ｙは得点の最小化を狙う＝Ｘの邪魔をする
山札内の得点の最大化をできるカードをＸが選んでも、Ｙはそれを邪魔する動きをとるので、真に最大化すること(Xの狙いを達成すること)はできない
→選べるのはＹの初期値＆山札最後（Ｘがすべて取る）か、最後とその一つ手前の比較（Ｘが一枚残してすべて取る）のどちらかにするのがましな選択



"""


n,x,y = map(int, input().split())

a = list(map(int, input().split()))

if n == 1:
        print(abs(a[-1] - y))
else:
        print(max(abs(y-a[-1]), abs(a[-1] - a[-2])))

Solution (Python):
N, Z, W = map(int, input().split())
As = list(map(int, input().split()))
if len(As) == 1:
    print(abs(As[0]-W))
else:
    print(max(abs(As[-1]-W), abs(As[-1]-As[-2])))

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,z,w = f()
    a = f()

    print(max(abs(a[n-1] - w), abs(a[n-2] - a[n-1])))

solve()

Solution (Python):


N,Z,W = map(int,input().split())
A = [int(x) for x in input().split()]

answer = abs(A[-1]-W)
if N > 1:
  answer = max(abs(A[-1]-A[-2]),answer)

print(answer)

Solution (Python):
n, z, w = map(int, input().split())
a = list(map(int, input().split()))

score = []


score.append(abs(a[-1] - w))

if n > 1:
    
    score.append(abs(a[-2] - a[-1]))

print(max(score))

Solution (Python):
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, Z, W = list(map(int, input().split()))
A = list(map(int, input().split()))

ans = abs(A[-1] - W)
if N > 1:
    ans = max(ans, abs(A[-1] - A[-2]))
print(ans)

Solution (Python):
import functools
import os
import sys
import numpy as np


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        ret = fn(*args, **kwargs)
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        print(ret)
        return ret

    return wrapper


sys.setrecursionlimit(10000)
INF = float('inf')

N, Z, W = list(map(int, input().split()))
A = list(map(int, input().split()))

































































dpx = np.empty(N + 1)

dpy = np.empty(N + 1)

dpx.fill(np.inf)
dpy.fill(-np.inf)
for i in reversed(range(1, N)):
    y = A[i - 1] if i > 0 else W
    dpx[i] = max(abs(A[-1] - A[i - 1]), dpy[i + 1])
    dpx[i] = min(dpx[i], dpx[i + 1])

    dpy[i] = min(abs(A[-1] - A[i - 1]), dpx[i + 1])
    dpy[i] = max(dpy[i], dpy[i + 1])

print(int(max(abs(A[-1] - W), dpy[1])))

Solution (Python):
n,z,w=map(int,input().split())
a=[int(i) for i in input().split()]
if n>=2:
    print(max(abs(a[-1]-w),abs(a[-1]-a[-2]) ))
else:
    print(abs(a[-1]-w))

Solution (Python):
n,z,w = map(int,input().split())
a = list(map(int,input().split()))
if n==1:
    print(abs(a[0]-w))
else:
    print(max(abs(w-a[-1]),abs(a[-1]-a[-2])))

Solution (Python):
N,Z,W = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
if(N!=1):
    if(abs(a[-1]-W)>abs(a[-2]-a[-1])):
        print(abs(a[-1]-W))
    else:
        print(abs(a[-2]-a[-1]))
else:
    print(abs(a[-1]-W))

Solution (Python):
import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N, Z, W = map(int, input().split())
    a = list(map(int, input().split()))
    if N == 1:
        print(abs(a[0] - W))
    else:
        print(max(abs(a[-1] - W), abs(a[-1] - a[-2])))


if __name__ == '__main__':
    main()

Solution (Python):
N,Z,W = map(int,input().split())
a = list(map(int,input().split()))
ans = abs(W-a[-1])
if N > 1:
    ans = max(ans,abs(a[-1]-a[-2]))
print(ans)

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, z, w = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    print(abs(a[0] - w))
    exit()
mx = max(abs(a[n - 2] - a[n - 1]), abs(a[-1] - w))

print(mx)

Solution (Python):
n,z,w=(map(int,input().split()))
l=list(map(int,input().split()))
if n==1:
    print(abs(l[0]-w))
else:
    print(max(abs(l[-1]-w),abs(l[-1]-l[-2])))

Solution (Python):
N,Z,W = list(map(int, input().split()))
A = [W] + list(map(int, input().split()))

X = [0]*(N+1)
Y = [1e9]*(N+1)

for i in range(N,0,-1):
  X[i] = max([abs(A[i-1] - A[N])] + [Y[j] for j in range(i+1,N+1)])
  Y[i] = min([abs(A[i-1] - A[N])] + [X[j] for j in range(i+1,N+1)])

print(X[1])

Solution (Python):
N, X, Y = map(int, input().split())
A = list(map(int, input().split()))

if N > 1:
    print(max(abs(A[-1] - Y), abs(A[-1] - A[-2])))
else:
    print(abs(A[-1] - Y))

Solution (Python):
n, z, w = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

if n == 1:
    print(abs(a[0] - w))
    exit()

last = a[-1]
prev = a[-2]
print(max(abs(last - prev), abs(last - w)))

Solution (Python):
a,b,c = map(int, input().split())
z = [int(_) for _ in input().split()]
if a == 1:
  sco = abs(z[0]-c)
else:
  if abs(z[-1] - c) > abs(z[-2] - z[-1]):
    sco = abs(z[-1] - c)
  else:
    sco = abs(z[-2] - z[-1])
    
print(sco)

Solution (Python):
n,z,w=map(int,input().split())
a=list(map(int,input().split()))
print(max(abs(a[-1]-w),abs(a[-2]-a[-1])if n!=1 else 0))

Solution (Python):
n,z,w = map(int,input().split())
A = list(map(int,input().split()))
if n == 1:
	print(abs(A[0]-w))
else:
	print(max(abs(A[-1]-w),abs(A[-1]-A[-2])))

Solution (Python):
n,z,w = map(int,input().split())
A = list(map(int,input().split()))
if n == 1:
	print(abs(A[0]-w))
else:
	print(max(abs(A[-1]-w),abs(A[-1]-A[-2])))

Solution (Python):
n, z, w = map(int, input().split())
a = list(map(int, input().split()))
c = abs(a[n-1] - w)
d = 0
if n-2 >= 0:
    d = abs(a[n-2] - a[n-1])
print(max(c, d))

Solution (Python):
n, z, w = map(int, input().split())
a = list(map(int, input().split()))
if n > 1:
    print(max(abs(a[-1] - w), abs(a[-2] - a[-1])))
else:
    print(abs(a[-1] - w))

Solution (Python):
N, Z, W = map(int, input().split())
if N == 1:
    a = int(input())
    print(abs(a - W))
else:
    a = list(map(int, input().split()))
    print(max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1])))

Solution (Python):
N,Z,W =list(map(int,input().split()))

A=list(map(int,input().split()))
if(N==1):
    print(abs(A[0]-W))
else:
    print(max(abs(W-A[-1]),abs(A[-1]-A[-2])))

Solution (Python):
n,x,y = map(int,input().split())

A = list(map(int,input().split()))









X = [0]*n
Y = [0]*n
dpX = list(range(n)) 
dpY = list(range(n)) 

for i in range(n):
    X_bound = 10**18+1
    Y_bound = -10**18-1
    for j in range(i+1,n):
        X_bound = min(X_bound,abs(A[j]-A[i]))
        Y_bound = max(Y_bound,abs(A[j]-A[i]))
    X[i] = X_bound
    Y[i] = Y_bound

X[n-1] = -10**18-1
Y[n-1] = 10**18+1

for i in range(n-2,-1,-1):
    if X[dpX[i+1]]>X[i]:
        dpX[i] = dpX[i+1]
    if Y[dpY[i+1]]<Y[i]:
        dpY[i] = dpY[i+1]






curr = 0
hisatsuX = []
hisatsuY = []
while curr<n:
    hisatsuX.append(abs(A[-1]-y))
    if X[dpX[curr]]<abs(A[-1]-y):
        curr = n
        x = A[-1]
    else:
        x = A[dpX[curr]]
        curr = dpX[curr]+1
    
    hisatsuY.append(abs(A[-1]-x))
    if curr >= n:
        break
    if Y[dpY[curr]]>abs(A[-1]-x):
        curr = n
        y = A[-1]
    else:
        y = A[dpY[curr]]
        curr = dpY[curr]+1
    
for i in range(len(hisatsuX)):
    if hisatsuX[i] >= abs(x-y):
        print(hisatsuX[i])
        exit(0)
    if hisatsuY[i] <= abs(x-y):
        print(hisatsuY[i])
        exit(0)
print(abs(x-y))

Solution (Python):
N,Z,W=map(int,input().split())
A=list(map(int,input().split()))
if N>=2:
    print(max(abs(A[-1]-W),abs(A[-2]-A[-1])))
elif N==1:
    print(abs(A[-1]-W))

Solution (Python):
N,Z,W  = map(int,input().split())
a = list(map(int,input().split()))

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

Solution (Python):
a = list(map(int, input().split()))  
b = list(map(int, input().split()))

try:
    print(max(abs(a[2] - b[-1]), abs(b[-1] - b[-2]))) 
except:  
    print(abs(a[2] - b[0]))

Solution (Python):
n,z,w = map(int,input().split())
a = list(map(int,input().split()))


ans1 = a[-1]-w

if len(a) > 1:
  ans2 = a[-2]-a[-1]
else:
  ans2 = 0

print(max(abs(ans1),abs(ans2)))

Solution (Python):
from sys import exit
N,Z,W = [int(n) for n in input().split()]
a = [int(n) for n in input().split()]




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

Solution (Python):
def _abs(N: int, Z: int, W: int, A: list) -> int:
    if N == 1:
        return abs(A[0] - W)
    return max(abs(A[N-1] - A[N-2]), abs(A[N-1] - W))


if __name__ == "__main__":
    N, Z, W = map(int, input().split())
    A = [int(s) for s in input().split()]
    ans = _abs(N, Z, W, A)
    print(ans)

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    n, z, w = map(int, input().split())
    A = list(map(int, input().split()))

    if n == 1:
        print(abs(w - A[0]))
    else:
        print(max(abs(w - A[-1]), abs(A[-1] - A[-2])))


    


if __name__ == '__main__':
    main()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


def A():
    s = LS()
    t = sorted(s)
    if s[0] == s[1]:
        print("=")
    elif s[0] == t[0]:
        print("<")
    else:
        print(">")


def B():
    x,y,z = LI()
    k = 0
    for i in range(1000000000):
        k += y+z
        if k+z>x:
            print(i)
            quit()


def C():
    n,m = LI()
    print((100*n+1800*m)*2**m)

def D():
    n,z,w = LI()
    a = LI()
    if len(a) == 1:
        print(abs(a[0]-w))
    else:
        print(max(abs(a[-1]-w),abs(a[-2]-a[-1])))

def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == "__main__":
    D()

Solution (Python):
N, Z, W = map(int, input().split())
a = list(map(int, input().split()))
if len(a) == 0:
    print(abs(a[0] - W))
else:
    print(max(abs(a[N - 1] - W), abs(a[N - 1] - a[N - 2])))

Solution (Python):
n,z,w = map(int,input().split())
li = list(map(int,input().split()))
print(max(abs(li[len(li)-1]-w),abs(li[len(li)-2]-li[len(li)-1])))

Solution (Python):
N,Z,W = map(int,input().split())
L = list(map(int,input().split()))
if N == 1:
  print(abs(L[0]-W))
else:
  print(max(abs(L[N-1]-W),abs(L[N-2]-L[N-1])))

Solution (Python):
n, _, w = map(int, input().split())
a = list(map(int, input().split()))
a = [w] + a
dp = [[0 for _ in range(2)] for _ in range(n+1)]
for i in range(n, 0, -1):
    dp[i][0] = abs(a[n] - a[i-1])
    dp[i][1] = abs(a[n] - a[i-1])
    for j in range(1, n-i+1):
        dp[i][0] = max(dp[i][0], dp[i+j][1])
        dp[i][1] = min(dp[i][1], dp[i+j][0])
print(dp[1][0])

Solution (Python):
n,z,w = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
  print(abs(a[0]-w))
else:
  print(max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])))

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,z,w=IL()
a=IL()
if n==1:
    print(abs(a[-1]-w))
else:
    print(max(abs(a[-1]-w),abs(a[-1]-a[-2])))

Solution (Python):
n,z,w = map(int,input().split())
a = list(map(int,input().split()))

if n>1:
    ko = abs(w-a[-1])
    ki = abs(a[-2]-a[-1])

    print(max(ko,ki))
else:
    print(abs(a[0]-w))

Solution (Python):
n, z, w = map(int, input().split())
a = list(map(int, input().split()))
print(max(abs(a[n-1]-w), abs(a[n-1]-a[n-2])) if n > 1 else abs(a[n-1]-w))

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, Z, W] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    A = []
    input_raw = read_func().strip().split()
    for i in range(N):
        A.append(int(input_raw[i]))

    if N == 1:
        print abs(A[0] - W)
    else:
        print max(abs(A[N - 2] - A[N - 1]), abs(A[N - 1] - W))

if __name__ == '__main__':
    main()

Solution (Python):
N, Z, W = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

if N == 1:
    print(abs(W - a[0]))
elif N == 2:
    print(max(abs(a[1] - a[0]), abs(a[1] - W)))
elif N>=3:
    print(max(abs(a[-1] - W), abs(a[-1] - a[-2])))

Solution (Python):
N, Z, W = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

if N == 1:
    print(abs(W - a[0]))
elif N == 2:
    print(max(abs(a[1] - a[0]), abs(a[1] - W)))
elif N>=3:
    print(max(abs(a[-1] - W), abs(a[-1] - a[-2])))

Solution (Python):
N, Z, W = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

if N == 1:
    print(abs(W - a[0]))
elif N == 2:
    print(max(abs(a[1] - a[0]), abs(a[1] - W)))
elif N>=3:
    print(max(abs(a[-1] - W), abs(a[-1] - a[-2])))

Solution (Python):

a,b,c=map(int,input().split())
x = list(map(int,input().split()))
if a == 1:
    print(abs(c-x[-1]))
else:
    print(max(abs(c-x[-1]),abs(x[-1]-x[-2])))

Solution (Python):
N,Z,W=map(int,input().split())
a=list(map(int,input().split()))

print(max(abs(a[N-2]-a[N-1]),abs(a[N-1]-W)))

Solution (Python):
N,Z,W = map(int,input().split())
a = list(map(int,input().split()))
A = abs(a[-1]-W)
if N == 1:
    print(A)
else:
    B = abs(a[-2]-a[-1])
    print(max(A,B))

Solution (Python):
n, z, w = list(map(int, input().split()))
li = list(map(int, input().split()))

ans = abs(w - li[-1])
if len(li) > 1:
    ans = max(ans, abs(li[-1] - li[-2]))

print(ans)

Solution (Python):


N, Z, W = map(int, input().split())
a = list(map(int, input().split()))

print(max([abs(a[N - 1] - a[N - 2]), abs(a[N - 1] - W)]))

Solution (Python):
n,z,w = map(int,input().split())
a = list(map(int,input().split()))
if n == 1:
    print(abs(a[0] - w))
else:
    print(max(abs(a[-2] - a[-1]), abs(a[-1] - w)))

Solution (Python):
N, Z, W = map(int, input().split())
a = list(map(int, input().split()))
if N == 1:
    print(abs(a[0]-W))
else:
    print(max(abs(a[N-1]-W), abs(a[N-1]-a[N-2])))

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)

n, z, w = map(int, input().split())
a = list(map(int, input().split()))

cache = {}

def f(idx, turn, x, y):
    if idx == n:
        return abs(x - y)
    
    key = (idx, turn)
    if key in cache:
        return cache[key]

    if turn == 0:
        ans = -float('inf')
        for i in range(idx, n):
            ans = max(ans, f(i + 1, 1 - turn, a[i], y))
    else:
        ans = float('inf')
        for i in range(idx, n):
            ans = min(ans, f(i + 1, 1 - turn, x, a[i]))

    cache[key] = ans
    return cache[key]

print(f(0, 0, z, w))

Solution (Python):


"""
参考：https://img.atcoder.jp/arc085/editorial.pdf
・公式解、O(1)の一発解法
・思いつけばいいけど、そういつも上手くいかないよね…。
"""
 
N, Z, W = map(int, input().split())
aN = list(map(int, input().split()))

if N == 1:
    print(abs(aN[0] - W))
else:
    
    print(max(abs(aN[-1] - W), abs(aN[-2] - aN[-1])))

Solution (Python):


"""
参考：https://kimiyuki.net/writeup/algo/atcoder/arc-085-d/
　　　https://atcoder.jp/contests/abc078/submissions/3854338
・ミニマックス法
・メモ化再帰
・メモの持ち方をシンプルにした版
"""

import sys
from collections import defaultdict


sys.setrecursionlimit(10 ** 9)
 
N, Z, W = map(int, input().split())
aN = list(map(int, input().split()))


memo = [[0] * (N+1) for _ in range(2)]

def dfs(turn, rest, x, y):
    if rest == 0:
        return abs(x - y)
    
    if turn % 2 == 0:
        
        if memo[0][rest]: 
            return memo[0][rest]
        mx = -1
        for i in range(N-rest, N):
            x = aN[i]
            idx = i+1
            mx = max(dfs(turn+1, N-idx, x, y), mx)
        
        memo[0][rest] = mx
        return mx
    
    else:
        if memo[1][rest]: 
            return memo[1][rest]
        mn = float('inf')
        for i in range(N-rest, N):
            y = aN[i]
            idx = i+1
            mn = min(dfs(turn+1, N-idx, x, y), mn)
        memo[1][rest] = mn
        return mn

print(dfs(0, N, Z, W))

Solution (Python):


"""
参考：https://kimiyuki.net/writeup/algo/atcoder/arc-085-d/
・ミニマックス法
・メモ化再帰
・先手と後手にそれぞれのメモを作る
"""

import sys
from collections import defaultdict


sys.setrecursionlimit(10 ** 9)
 
N, Z, W = map(int, input().split())
aN = list(map(int, input().split()))



memo1 = [defaultdict(int) for _ in range(N+1)]
memo2 = [defaultdict(int) for _ in range(N+1)]

def dfs(turn, rest, x, y):
    if rest == 0:
        return abs(x - y)
    
    if turn % 2 == 0:
        
        if memo1[rest][y]: 
            return memo1[rest][y]
        mx = -1
        for i in range(N-rest, N):
            x = aN[i]
            idx = i+1
            mx = max(dfs(turn+1, N-idx, x, y), mx)
        
        memo1[rest][y] = mx
        return mx
    
    else:
        if memo2[rest][x]: 
            return memo2[rest][x]
        mn = float('inf')
        for i in range(N-rest, N):
            y = aN[i]
            idx = i+1
            mn = min(dfs(turn+1, N-idx, x, y), mn)
        memo2[rest][x] = mn
        return mn

print(dfs(0, N, Z, W))

Solution (Python):
N,Z,W=map(int,input().split())
a=[int(i) for i in input().split()]
if N==1:
    print(abs(a[0]-W))
else:
    print(max(abs(a[N-1]-W),abs(a[N-1]-a[N-2])))

Solution (Python):
N, X, Y = map(int, input().split())
A = list(map(int, input().split()))

if N == 1:
    print(abs(A[-1] - Y))
else:
    print(max(abs(A[-1] - Y), abs(A[-2] - A[-1])))

Solution (Python):
N, Z, W, *A = map(int, open(0).read().split())
ans = abs(A[-1] - W)
if N >= 2:
    ans = max(ans, abs(A[-2] - A[-1]))
print(ans)

Solution (Python):
n,z,w = map(int,input().split())
a = list(map(int,input().split()))
if n == 1:
    print(abs(a[0] - w))
    exit()
else:
    print(max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])))

Solution (Python):
n, z, w = map(int, input().split())
a = input().split()
a = [int(m) for m in a]
if n == 1:
    print(abs(a[n - 1] - w))
else:
    print(max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2])))

Solution (Python):
n, z, w = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    ans = abs(a[0]-w)
else:
    ans = max(abs(a[-1]-w), abs(a[-2]-a[-1]))
print(ans)

Solution (Python):
N,Z,W = list(map(int,input().split()))
a = list(map(int,input().split()))
if len(a)>1:
    ans = max(abs(a[-1]-a[-2]), abs(W-a[-1]))
else:
    ans = abs(W-a[-1])
print(ans)

Solution (Python):
n, z, w = map(int, input().split())
x = list(map(int, input().split()))
if n == 1:
    print(abs(x[0]-w))
else:
    print(max(abs(x[-1]-w), abs(x[-2]-x[-1])))

Solution (Python):
N, Z, W = map( int, input().split())
A = list( map( int, input().split()))

if N == 1:
    print( abs(A[0]-W))
else:
    print( max( abs(A[-1]-W), abs(A[-2]-A[-1])))

Solution (Python):
def main():
    N, Z, W = map(int, input().split())
    A = list(map(int, input().split()))
    if N >= 2:
        print(max(abs(W - A[-1]), abs(A[-2] - A[-1])))
    else:
        print(abs(W - A[-1]))


if __name__ == "__main__":
    main()

Solution (Python):
n,z,w = map(int,input().split())
lis = list(map(int,input().split()))
if n == 1:
    print(abs(lis[-1]-w))
else:
    print(max(abs(lis[-1]-w),abs(lis[-1]-lis[-2])))

Solution (Python):
N, X, Y = map(int, input().split())
A = list(map(int, input().split()))

if N >= 2:
    print(max(abs(A[-1] - Y), abs(A[-1] - A[-2])))
else:
    print(abs(A[-1] - Y))

Solution (Python):

from collections import Counter
def inpl(): return list(map(int, input().split()))
N, Z, W = inpl()
A = inpl()

if N == 1:
    print(abs(A[0] - W))
else:
    print(max(abs(A[-1] - W),
              abs(A[-2] - A[-1])))

Solution (Python):
n, z, w = map(int, input().split())
a = list(map(int, input().split()))

if n == 1:
    print(abs(a[0] - w))
else:
    print(max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])))

Solution (Python):
N,Z,W = map(int,input().split())
a = list(map(int,input().split()))
print(max(abs(W-a[N-1]),abs(a[N-2]-a[N-1])))

Solution (Python):

"""
Created on Sun Oct 21 11:28:35 2018
ABC078D
@author: maezawa
"""

n, z, w = list(map(int, input().split()))
a = list(map(int, input().split()))








cand = [abs(w-a[-1])]
for card in a[-2:]:
    cand.append(abs(card-a[-1]))

score = max(cand)
print(score)

Solution (Python):
N,Z,W = list(map(int,input().split()))

a=[W]+list(map(int,input().split()))

print(max(abs(a[-1]-a[-2]),abs(a[-1]-W)))

Solution (Python):
N,Z,W = map(int,input().split())
A = list(map(int,input().split()))
if len(A) == 1 :
    print(abs(A[-1]-W))
else :
    p = abs(A[-1]-W)
    q = abs(A[-1]-A[-2])
    print(max(p,q))

Solution (Python):
n, z, w = map(int, input().split())
a = list(map(int, input().split()))

print(max(abs(a[n-1]-w), abs(a[n-2]-a[n-1])))

Solution (Python):
N,Z,W = map(int,input().split())
src = list(map(int,input().split()))

score1 = abs(src[-1] - W)
score2 = abs(src[-2] - src[-1]) if N>1 else 0
print(max(score1, score2))

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,z,w = li()
a = list(li())

if n == 1:
    print(abs(w-a[-1]))
else:
    print(max(abs(a[-2]-a[-1]), abs(w-a[-1])))

Solution (Python):
n,z,w=map(int,input().split())
a=list(map(int,input().split()))
print(max(abs(a[n-2]-a[n-1]),abs(a[n-1]-w)))

Solution (Python):
import sys
sys.setrecursionlimit(114514)

n, z, w = map(int, input().split())
aa = list(map(int, input().split()))

memo = {}
def act(last, turn):
    if (last, turn) in memo:
        return memo[(last, turn)]

    if turn == 0:
        
        y = w if last == -1 else aa[last]
        ans = abs(y - aa[n - 1])
        for i in range(last + 1, n - 1):
            ans = max(ans, act(i, 1))
    else:
        
        x = z if last == -1 else aa[last]
        ans = abs(x - aa[n - 1])
        for i in range(last + 1, n - 1):
            ans = min(ans, act(i, 0))
    
    memo[(last, turn)] = ans
    return ans


print(act(-1, 0))

Solution (Python):
N, Z, W = map(int, input().split())
a = [int(i) for i in input().split()]

if N == 1:
	ans = abs(a[N-1]-W)
else:
	ans = max(abs(a[N-1]-W), abs(a[N-2]-a[N-1]))

print(ans)

Solution (Python):
n, z, w = list(map(int, input().split()))
a = list(map(int, input().split()))

if n == 1:
    print(abs(a[0]-w))
else:
    ans1 = abs(a[-1] - w)
    ans2 = abs(a[-2] - a[-1])
    print(max(ans1, ans2))

Solution (Python):
n,z,w= map(int,input().split())
a = input().rstrip().split()

print(max(abs(int(a[n-1])-w),abs(int(a[n-2])-int(a[n-1]))))

Solution (Python):
N, Z, W=map(int, input().split())
a=list(map(int, input().split()))
if N==1:
    print(abs(a[0]-W))
else:
    print(max(abs(a[-1]-W), abs(a[-2]-a[-1])))

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N, Z, W = map(int, input().split())
    A = list(map(int, input().split()))
    if N == 1:
        print(abs(A[0] - W))
    else:
        print(max(abs(A[-1] - W), abs(A[-1] - A[-2])))


if __name__ == '__main__':
    main()

Solution (Python):
N, Z, W = map(int, input().split())
a_list = [i for i in map(int, input().split())]

if N == 1:
    print(abs(W-a_list[0]))
    exit()
    
max_a = max(a_list)
print(max(abs(a_list[-1]-W), abs(a_list[-2]-a_list[-1])))

Solution (Python):
n,z,w=map(int,input().split())
*a,=map(int,input().split())
b,c=max(a),min(a)
pb,pc=a.index(b),a.index(c)  
if n<=1:
  print(abs(a[0]-w))
else:
  print(max(abs(a[n-1]-w),abs(a[n-2]-a[n-1])))