#include using namespace std; typedef long long ll; typedef pair P; #define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0) #define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0) ll gcd(ll a,ll b) { while (b) { a %= b; swap(a,b); } return a; } int main() { int n;cin >> n; vector a(1000000),c; for (int i = 0;i < n;++i) cin >> a[i]; c = a; // for (int i = 0;i < 20;++i) if ((n>>i)&1) b = i; for (int i = 0;i < 19;++i) for (int j = 0;j < n;++j) if (!(j&(1< -1) { if (c[i|(1< -1) c[j] += c[i|(1< -1) ans = gcd(ans,gcd(ans,a[i])*gcd(ans,c[i])); if (ans == 0) cout << -1 << endl; else cout << ans << endl; }