import math, functools n = int(input()) a = [int(w) for w in input().split() if int(w)>0] print(functools.reduce(math.gcd, a)**2 if a else -1)