program main
Implicit None
	integer(8)::n,p1,p2,p3,x,y
	integer(8),allocatable::a(:)
	
	read*,n
	allocate(a(n))
	
	read*,a
	
	if(n == 2)then
		print"(i0)",max(a(1),a(2))
		stop
	endif
	
	x = 1 ;y = 2
	call ec(a,n,x,y,p1)
	y = 3
	call ec(a,n,x,y,p2)
	x = 2
	call ec(a,n,x,y,p3)
	
	print"(i0)",max(p1,p2,p3)
end program main

recursive subroutine ec(a,n,p,q,c)
Implicit None
	integer(8)::a(n),n,p,q,c,i,j,k,t
	
	k = 0
	call euc(a(p),a(q),c)
	do i = 1,n
		if(mod(a(i),c) /= 0)then
			if(k == 0) t = i
			k = k+1
			if(k > 1)then
				call ec(a,n,p,t,c)
				exit
			endif
		endif
	enddo
end subroutine ec

subroutine euc(a1,b1,c)
implicit None
integer(8)::a1,b1,c,a,b
	a = a1
	b = b1
	c = 1
	
	do while (a /=0 .and. b /= 0)
		if (a > b)then
			c = b
			a = mod(a,b)
			else
			c = a
			b = mod(b,a)
		endif
	enddo
end subroutine euc