n,x=io.read("*n","*n")
city={x}
for i=1,n do
    table.insert(city,io.read("*n"))
end
table.sort(city)

d=10^9+1
if #city>1 then
    for i=2,n+1 do
        d=math.min(d,city[i]-city[i-1])
    end
else
    d=city[1]-x
end
print(d)