import math n = int(input()) A = list(map(int, input().split())) fixed = [] for a in A: if a != -1: fixed.append(a) if not fixed: print(-1) else: g = fixed[0] for num in fixed[1:]: g = math.gcd(g, num) print(g * g)