program main
	implicit none
	integer n,z,w
	integer,allocatable,dimension(:)::a
	read(*,*)n,z,w
	allocate(a(n))
	read(*,*)a(1:n)
	z=max(maxval(a),z)
	w=min(minval(a(2:n)),w)
	write(*,*)abs(z-w)
end program main
