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):
n,z,w = map(int,input().split())
a = list(map(int,input().split()))

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

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

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

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N, Z, W = in_nn()
    A = in_nl()

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

    print(ans)


if __name__ == '__main__':
    main()

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):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,Z,W = LI()
    a = LI()

    s = abs(W - a[-1])
    if N == 1:
        print(s)
        return

    u = [0] * N
    d = [0] * N

    u[-2] = d[-2] = min_u = max_d = abs(a[-1] - a[-2])
    for i in range(N-3,-1,-1):
        u[i] = max(max_d,abs(a[i]-a[-1]))
        d[i] = min(min_u,abs(a[i]-a[-1]))
        min_u = min(min_u,u[i])
        max_d = max(max_d,d[i])

    print(max(s,max_d))
if __name__ == '__main__':
    main()

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







if N == 1:
    ans = abs(a[-1] - W)
else:
    ans = max(abs(a[-1] - W), 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(W-a[0]))
else:
    print(max(abs(a[-1]-a[-2]),abs(W-a[-1])))

Solution (Python):
n, _, w = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    print(abs(a[-1] - 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()))

ans = max(
  abs(A[-2] - A[-1]) if len(A) > 1 else 0,
  abs(A[-1] - w)
)

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))
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()))
print(max(abs(A[N-1]-A[N-2]),abs(A[N-1]-W)))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, z, w = map(int, input().split())
    A = list(map(int, input().split()))

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


if __name__ == '__main__':
    resolve()

Solution (Python):
import numpy as np

def solve(N, Z, W, A):
    
    dp_x = np.full(N+1, 1<<61, dtype=np.int64)
    dp_y = np.zeros(N+1, dtype=np.int64)
    for i in range(N-1, 0, -1):
        dp_x[i] = max(dp_y[i+1:].max(), abs(A[-1]-A[i-1]))
        dp_y[i] = min(dp_x[i+1:].min(), abs(A[-1]-A[i-1]))
    ans = max(abs(A[-1]-W), dp_y[1:].max())
    return ans

N, Z, W = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
ans = solve(N, Z, W, A)
print(ans)

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

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

Solution (Python):
import sys
input = sys.stdin.readline

N, Z, W = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0]*(2) for _ in range(N)]

for i in range(N-1, -1, -1):
    if i==0:
        dp[i][0] = abs(a[N-1]-W)
    else:
        dp[i][0] = abs(a[N-1]-a[i-1])
    
    for j in range(i+1, N):
        dp[i][0] = max(dp[i][0], dp[j][1])
    
    if i==0:
        dp[i][1] = abs(a[N-1]-Z)
    else:
        dp[i][1] = abs(a[N-1]-a[i-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())
a=list(map(int,input().split()))
if n==1:
    print(abs(a[0]-w))
else:
    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 n == 1:
  print(abs(w-a[-1]))
else:
  print(max(abs(w-a[-1]), abs(a[-1]-a[-2])))

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())
As = list(map(int, input().split()))

max_score = abs(As[-1] - W)
if N >= 2 and max_score < abs(As[-2] - As[-1]):
    max_score = abs(As[-2] - As[-1])

print(max_score)

Solution (Python):
N, Z, W = map(int,input().split())
A = list(map(int,input().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))
else:
    print(max(abs(a[-1]-W), abs(a[-1]-a[-2])))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, X, Y = mapint()
As = list(mapint())

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

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

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

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

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

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

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

Solution (Python):
N, Z, W = map(int, input().split())
*a, = 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):
import sys
from itertools import product
input = sys.stdin.readline

def main():
    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[-2]-a[-1]))
    
    print(ans)
        

    
if __name__ == "__main__":
    main()

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

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	
	n, x, y = tin()
	
	if n == 1:
		return abs(int(input())-y)
	else:
		al=lin()
		return max(abs(al[-1]-y), abs(al[-2]-al[-1]))
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

"""
xの選択肢は2つ。最後を取ってwと比較するか、最後から2番目を取って最後と比較する
"""

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

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

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

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

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):
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):
n,z,w=list(map(int,input().split()))
a=list(map(int,input().split()))

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

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7





N, Z, W = getNM()
A = getList()


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()))
print(abs(W-a[0])if N==1 else max(abs(W-a[-1]),abs(a[-1]-a[-2])))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10**7)

def main():
    N, Z, W = map(int, input().split())
    A = list(map(int, input().split()))
    """
    O(N^2)dpでも行けるそうです。以下写経：
    https://atcoder.jp/contests/abc078/submissions/14886969
    dp[turn][top]の２引数だけでいいのか、[x][y]の２引数も必要ではないかと思うが、
    考えてみれば
        dfs(0, top, x, y) = dfs(1, top', A[top], y)
                          = dfs(0, top", A[top], A[top'])
    となるので、実はdfs(0, top, x, y)はtop = Nでない限りx, yに依らない。
    """
    dp = [[-1] * N for _ in range(2)]
    def dfs(turn, top, x, y): 
        if top == N: return abs(x - y)
        if dp[turn][top] != -1: return dp[turn][top]
        if turn == 1:
            """
            yのターンは、top以降を取ってなるべくスコアが低くなるようなiを選ぶ
            """
            ret = 10**9
            for i in range(top, N): ret = min(ret, dfs(0, i + 1, x, A[i]))
            dp[turn][top] = ret
            return ret
        else:
            """
            xのターンは、top以降を取ってなるべくスコアが高くなるようなiを選ぶ
            """
            ret = 0
            for i in range(top, N): ret = max(ret, dfs(1, i + 1, A[i], y))
            dp[turn][top] = ret
            return ret
    
    print(dfs(0, 0, Z, W))

if __name__ == "__main__":
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, z, w = map(int, input().split())
    A = list(map(int, input().split()))
    """
    dpかと思ってずっとウンウン唸ってたのに、解説見て唖然。。。
    """
    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()))
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 = [int(i) for i in input().split()]

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

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

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

if __name__ == '__main__':
    main()

Solution (Python):
n, z, w = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    print(abs(a[0]-w))
    exit()
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))
    exit()
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))
    exit()
print(max(abs(a[-1]-w), abs(a[-1]-a[-2])))

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

Solution (Python):
N, Z, W = map(int, input().split())
a = [0]*N
*a, = map(int, input().split())

dpx = [0]*(N+1)
dpy = [0]*(N+1)
x = [Z]+a[:]
y = [W]+a[:]

for i in range(1, N+1):
    if i == 1:
        dpx[i] = abs(x[N] - y[N-1])
        dpy[i] = abs(y[N] - x[N-1])
    else:
        dpx[i] = max([abs(x[N] - y[N-i])] + [dpy[j] for j in range(1,i)])
        dpy[i] = min([abs(y[N] - x[N-i])] + [dpx[j] for j in range(1,i)])

print(dpx[N])

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

if n == 1:
  print(ans)
  exit()
  
l = len(a)
for i in range(l-1):
  chk = 10**9
  for j in range(i+1,l):
    if j == l-1:
      chk = min(chk,abs(a[i]-a[j]))
    else:
      chk = min(chk,abs(a[l-1]-a[j]))
  ans = max(ans,chk)
  
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))
else: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()))

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: print(abs(A[0]-W))
else:
    print(max(abs(A[-1]-A[-2]),abs(A[-1]-W)))

Solution (Python):
import sys
from io import StringIO
import unittest
import os


sys.setrecursionlimit(999999999)



def resolve(test_def_name=""):
    
    
    
    
    
    

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

    if len(a_s) >= 2:
        print(max(abs(a_s[-1] - w), abs(a_s[-2] - a_s[-1])))
    else:
        print(abs(a_s[-1] - w))


class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 100 100
10 1000 100"""
        output = """900"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """3 100 1000
10 100 100"""
        output = """900"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """5 1 1
1 1 1 1 1"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_4(self):
        test_input = """1 1 1
1000000000"""
        output = """999999999"""
        self.assertIO(test_input, output)

    
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)



if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        
        resolve()

    else:
        
        unittest.main()

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]-a[-2]),abs(a[-1]-w))
print(ans)

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

cand = []
cand.append( abs(A[N-1]-W))
cand.append( abs(A[N-2]-A[N-1]))

print(max(cand))

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:
    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:
    z1 = A[-1]
    w1 = A[-2]
    print(max(abs(z1-w), abs(z1-w1)))

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

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

Solution (Python):
import sys
readline = sys.stdin.readline





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

if N == 1:
  
  print(abs(A[0] - W))
  exit(0)
  

last_one = abs(A[-1] - W)


last_two = abs(A[-1] - A[-2])

if last_one > last_two:
  print(last_one)
else:
  print(last_two)

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

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *
sys.setrecursionlimit(2100)

def rec(sta, t):
    if memo[sta][t]!=-1:
        return memo[sta][t]
    
    if t==0:
        res = -10**18
        
        for i in range(sta, N):
            if i<N-1:
                res = max(res, rec(i+1, 1))
            else:
                if sta==0:
                    res = max(res, abs(a[N-1]-W))
                else:
                    res = max(res, abs(a[N-1]-a[sta-1]))
    else:
        res = 10**18
        
        for i in range(sta, N):
            if i<N-1:
                res = min(res, rec(i+1, 0))
            else:
                if sta==0:
                    res = min(res, abs(a[N-1]-Z))
                else:
                    res = min(res, abs(a[N-1]-a[sta-1]))
    
    memo[sta][t] = res
    
    return res

N, Z, W = map(int, input().split())
a = list(map(int, input().split()))
memo = [[-1]*2 for _ in range(N)]
print(rec(0, 0))

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, z, w = map(int, readline().split())
    a = list(map(int, readline().split()))

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


if __name__ == '__main__':
    main()

Solution (Python):
n,z,w=map(int,input().split())
a=list(map(int,input().split()))
b=[abs(a[i]-a[-1]) for i in range(n-1)]
b=[abs(w-a[-1])]+b
if n==1:print(abs(w-a[0]));exit()
print(max(abs(w-a[-1]),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[-1]-w), abs(a[-2]-a[-1])))

Solution (Python):
N, Z, W = map(int, input().split())
A = tuple(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[N-1]-a[N-2]),abs(a[N-1]-W)))

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

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

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

al1 = al[-2]
al2 = al[-1]

d1 = abs(al1-al2)
d2 = abs(al2-w)

print(max(d1,d2))

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

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

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,z,w = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    if n == 1:
        print(abs(w-a[0]))
    else:
        print(max(abs(w-a[-1]),abs(a[-2]-a[-1])))
    return

if __name__ == '__main__':
    main()

Solution (Python):
N,Z,W = (int(x) for x in input().split())
a = list(map(int, input().split()))
if N == 1:
    print(abs(W-a[0]))
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[-1] - w))
    exit()
ans = abs(a[-1] - a[-2])
tmp = abs(a[-1] - w)
print(max(ans, tmp))

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

dp = [[0, 0] for i in range(N)]
dp[-1][0] = abs(A[-1]- W)
dp[-1][1] = - 1
dp[-2][0] = dp[-2][1] = dp1min = abs(A[-2] - A[-1])
dp0max = max(dp1min, dp[-1][0])

for i in range(N-3, -1, -1):
  ai = A[i]
  diff = abs(ai - A[-1])
  dp[i][0] = min(diff, dp1min)
  dp[i][1] = max(diff, dp0max)
  dp0max = max(dp0max, dp[i][0])
  dp1min = min(dp1min, dp[i][1])

print(dp0max)

Solution (Python):
def main():
    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(A[-1] - W), abs(A[-2] - A[-1])]))


if __name__ == '__main__':
    main()

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, _, w = mi()
    L = lmi()
    if n == 1:
        print(abs(w - L[-1]))
    else:
        print(max(abs(w - L[-1]), abs(L[-1]-L[-2])))



if __name__ == "__main__":
    main()

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def Yes(): print("Yes"); return
def No(): print("No"); return


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]






N,Z,W = inputIL()
A = inputIL()

if len(A) ==1:
  print(abs(A[0]-W))
  exit()
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()))
print(abs(a[0] - w) if n == 1 else max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])))

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

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] - a[-2]), abs(a[-1] - w)))

Solution (Python):
N, Z, W = map(int,input().split())
A = list(map(int,input().split()))
idea = abs(A[-1] - W)
try: idea2 = abs(A[-2] - A[-1])
except:
    print(idea)
    quit()
print(max(idea,idea2))

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

if(abs(cards[len(cards)-1]-w)>abs(cards[len(cards)-1]-cards[len(cards)-2])):
    print(abs(cards[len(cards)-1]-w))
else:
    print(abs(cards[len(cards)-1]-cards[len(cards)-2]))

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

Solution (Python):
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, Z, W = read_values()
    A = read_list()
    res = V(max, abs(W - A[-1]))
    if N >= 2:
        res.ud(abs(A[-1] - A[-2]))

    print(res)


if __name__ == "__main__":
    main()

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())

al = list(map(int,input().split()))
if len(al) == 1:
    print(abs(al[-1] - w))
    exit()
ans1 = abs(al[-1] - al[-2])
ans2 = abs(al[-1] - w)

print(max(ans1, ans2))

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


t1=abs(a[N-1]-W)

if N>1:
    t2=abs(a[N-1-1]-a[N-1])
else:
    t2=0

if N>2:
    t3=min( abs(a[N-2-1]-a[N-1]),abs(a[N-1]-a[N-1-1]) )
else:
    t3=0

print(max(t1,t2,t3))

Solution (Python):
N, Z, W, *A = map(int, open(0).read().split())

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

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

def sort(a):
	a.sort()

def rev(a):
	a.reverse()

def sd():
	return int(input())

def _sd():
	return map(int,input().split())

def sa():
	return list(map(int,input().split()))

def ss():
	return input()

def sf():
	return float(input())
 
def main():
	N,Z,W=_sd()
	a=sa()
	if(N>1):
		print(max(abs(a[N-1]-W),abs(a[N-2]-a[N-1])))
	else:
		print(abs(a[0]-W))
main()

Solution (Python):

import sys
input = sys.stdin.buffer.readline


from collections import defaultdict

con = 10 ** 9 + 7

def getlist():
	return list(map(int, input().split()))


def main():
	N, Z, W = getlist()
	A = getlist()
	if N == 1:
		print(abs(A[0] - W))
	else:
		ans = max(abs(A[-1] - W), abs(A[-1] - A[-2]))
		print(ans)
	


if __name__ == '__main__':
	main()

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


print(main())

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])]))