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() g = 0 for a in A: if a != -1: g = gcd(g, a) print(g**2) if __name__ == '__main__': main()