from math import gcd n = int(input()) *a, = map(int,input().split()) g = 0 for i in a: g = gcd(g,max(i,0)) print(g*g if g else -1)