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