#include using namespace std; #include using namespace atcoder; using ll = long long; using vi = vector; using vvi = vector>; using pii = pair; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i) int gcd(int x, int y) { if (x > y) swap(x, y); return x == 0 ? y : gcd(y % x, x); } int main() { int n; cin >> n; vi a(n); rep(i, n) cin >> a[i]; int r = 0; rep(i, n) { if (a[i] >= 0) r = gcd(r, a[i]); } cout << (r == 0 ? -1 : (ll)r * r) << endl; return 0; }