from collections import Counter #N = 入力の最大 N = 1000000 + 100 sieve = [i for i in range(N + 1)] for i in range(2,N + 1): if sieve[i] == i: for j in range(2 * i, N + 1, i): sieve[j] = i def prime_fact(X): ret = Counter() while 1: ret[sieve[X]] += 1 if sieve[X] == X: break else: X //= sieve[X] return ret def divisors(N, b): div = [1] b[1] += 1 for p,a in prime_fact(N).items(): m = len(div) for i in range(m): for j in range(1, a+1): div.append(div[i] * p**j) b[div[i] * p ** j] += 1 return b n = int(input()) a = list(map(int,input().split())) #K = N - 1のとき答えはmax(a)になる #ではK = N - 2では?2個残さないといけないので、答えは2個選んだときの最大公約数の最大値 #同様にN - K個選んだ時の最大公約数の最大値になる #aの約数をマッピングしていく、N - K以上の最大値を探せばよい b = [0] * (10 ** 6 + 100) for i in range(n): b = divisors(a[i], b) ans = [0] * (n + 1) for i in range(10 ** 6 + 99): if b[i] != 0: ans[b[i]] = i ans.reverse() for i in range(n): ans[i] = max(ans[i], ans[i - 1]) print(ans[i])