# coding: utf-8 # Your code here! import sys readline = sys.stdin.readline read = sys.stdin.read n,*a = [int(i) if i != "-1" else 0 for i in read().split()] from math import gcd from functools import reduce g = reduce(gcd,a) if g: print(g*g) else: print(-1)