require 'prime'
n = gets.to_i
as = gets.split.map(&:to_i).select { |i| !i.prime? }

def solve(as)
    factors = []
    as.each { |i| factors << i.prime_division.flatten}
    gcd = as.inject{|a,b| a.gcd(b)}
    factors = factors.flatten.uniq
    if factors.size < 3
        return factors.sort[1]
    end
    min = factors.sort[1]
    return (gcd == as[0] || gcd == min)  ? gcd : gcd * min
end

puts solve(as)