require "prime" def f(a) pairs = a.map{|n| r = n.prime_division next [1, []] if r.empty? [n, r] } # p pairs r = [] while !pairs.empty? n, f = pairs.shift r << n pairs.sort_by!{|nn, ff| # p [nn, ff] t = f.inject(1){|r, (v, i)| # p [r, v, i] vv, ii = ff.assoc(v) vv ? r * v * [i, ii].min : r } [n * nn / t, nn] } end r end N = gets.to_i A = gets.split.take(N).map(&:to_i) puts f(A) * " "