#include using namespace std; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int GCD(int a,int b){ return b?GCD(b,a%b):a; } int N; int A[200000]; int main() { scanf("%d",&N); rep(i,N) scanf("%d",&A[i]); int ans=-1; rep(i,N){ if(ans==-1) ans=A[i]; else if(A[i]!=-1) ans=GCD(ans,A[i]); } if(ans==-1) printf("-1\n"); else printf("%lld\n",LL(ans)*LL(ans)); return 0; }