from collections import Counter n = int(input()) a = list(map(int, input().split())) c = Counter(a) anss = [0]*(n+1) for i in range(1, 10**6+1): num = n for j in range(i, 10**6+1, i): num -= c[j] anss[num] = max(anss[num], i) ans = anss[0] for i in range(n): ans = max(ans, anss[i]) print(ans)