from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N = int(input()) A = list(map(int,input().split())) def md(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] X = defaultdict(list) for i,a in enumerate(A): for p in md(a): X[p].append((a,i)) for k in X.keys(): X[k].sort() X[k] = deque(X[k]) called = [False]*N ans = [0] called[0]=True for _ in range(N-1): I = A[ans[-1]] idx = -1 G = (1<<60) jval = (1<<60) for p in md(I): if len(X[p])==0: continue val,jdx = X[p].popleft() while called[jdx]: if len(X[p])==0: break val,jdx = X[p].popleft() if called[jdx]: continue X[p].appendleft((val,jdx)) tmp = I*val//math.gcd(I,val) if tmp