def main(): import sys from fractions import gcd input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) if sum(A) == -N: print(-1) exit() B = [] for a in A: if a != -1: B.append(a) B.sort() g = B[0] for b in B[1:]: g = gcd(g, b) print(g**2) if __name__ == '__main__': main()