function gcd(x, y, z)
	return (x<z) and z or y == 0 and x or gcd(y, x % y, z)
end
n = io.read"*n"
a = {io.read((("*n"):rep(n)):match(("(*n)"):rep(n)))}
r=0
for i=1,n do
	t = {table.unpack(a)}
	t[i]=a[i+1] or a[i-1]
	for j=1,n-1 do
		t[1]=gcd(t[1],t[j+1],r)
	end
	r=t[1]
end
print(r)