program name
    implicit none
    integer(4):: n,i,maxgcd
    integer(4),allocatable:: a(:),l(:),r(:)

    read*, n
    allocate(a(n),l(0:n),r(n+1))
    read*, a(:)

    l(0) = 0
    l(1) = a(1)
    r(n) = a(n)
    r(n+1) = 0
    do i=2,n
        l(i) = gcd(l(i-1),a(i))
    end do

    do i=n-1,1,-1
        r(i) = gcd(r(i+1),a(i))
    end do

    maxgcd = r(2)



    do i=2,n-1
        maxgcd = max(maxgcd, gcd(l(i-1),r(i+1)))
    end do

    maxgcd = max(maxgcd,l(n-1))
    print*, maxgcd



contains
    recursive function gcd(x,y) result(ret)
        integer(4),intent(in):: x,y
        integer(4):: ret

        if (mod(x,y) == 0) then
            ret = y
            return
        end if

        ret = gcd(y,mod(x,y))
    end function
end program name