Imports System

Public Class Test
	Public Shared Sub Main()
        Dim s() As String
        Dim t() As String
        s = Split(Console.ReadLine())
        Dim n, z, w As Integer
        n = s(0)
        z = s(1)
        w = s(2)
        t = Split(Console.ReadLine())
        Dim a(n - 1) As Integer
        For i As Integer = 0 To n - 1
            a(i) = t(i)
        Next i
        Dim X As Integer = z
        Dim Y As Integer = w
        Dim turn As Boolean = True
        For i As Integer = 0 To n - 1
            If turn Then
    			If (a(i) > X) or (i=n-1) Then
                    X = a(i)
                    turn = False
                End If
            Else
    			If (a(i) < Y) or (i=n-1) Then
                    Y = a(i)
                    turn = True
                End If
            End If
        Next
        Console.WriteLine(Math.Abs(Y - X))
	End Sub
End Class