function Getnum(number1,number2)
	local intTemp=1;
	if number2 < number1 then
		intTemp=number2;
		number2=number1;
		number1=intTemp;
	end
	while(number1~=0) do
		intTemp =number2 % number1;
		number2=number1;
		number1=intTemp;
	end
	return number2;
end

local n = io.read()
local x = io.read()
local s = {}
local sum = s[1]
for i=1,n do
	a = io.read()
	s[i] = a>x and a-x or x-a
end

for i=1,n-1 do
	sum = Getnum(sum,s[i+1])
end

print(sum)