#include #include using namespace std; const int inf = 1012345678; int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int main() { int N; cin >> N; int g = inf; for (int i = 0; i < N; ++i) { int x; cin >> x; if (x != -1) { if (g == inf) g = x; else g = gcd(g, x); } } if (g == inf) cout << -1 << endl; else cout << 1LL * g * g << endl; return 0; }