from math import gcd from collections import deque def lcm(x,y): return x*y//gcd(x,y) N=int(input()) A=list(map(int,input().split())) ANS=[A[0]] X=sorted(A[1:]) USE=[0]*(N-1) FACS=[[] for i in range(10001)] DIVS=[[] for i in range(10001)] x=ANS[-1] K=[] for j in range(1,min(100,x+1)): if x%j==0: K.append(j) FACS[x]=K for x in X: K=[] for j in range(1,min(100,x+1)): if x%j==0: K.append(j) FACS[x]=K for k in K: DIVS[k].append(x) for i in range(N-1): #print(DIVS[:10]) a=ANS[-1] MIN=1<<30 now=1000000 for k in FACS[a]: if len(DIVS[k])==0: continue l=lcm(DIVS[k][0],a) if l