import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np NA = np.fromstring(read(), np.int64, sep=' ') A = NA[1:] A[A < 0] = 0 g = np.gcd.reduce(A) if g == 0: print(-1) else: print(g * g)