#include using namespace atcoder; #include template inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}} template inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}} #define ll long long #define double long double #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i,n) for(int i=1;i<=(n);i++) #define mod (ll)(1e9+7) #define inf (ll)(3e18+7) #define eps (double)(1e-9) #define pi (double) acos(-1) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() using namespace std; struct smart_sieve{ int n; vector f; // 初期構築 : (nloglog(n)) smart_sieve(int x = 1) :n(x), f(x+1, -1){ for(ll i = 2; i <= n; i++){ if(f[i] != -1)continue; for(ll j = i*i; j <= n; j += i){ f[j] = (f[j] == -1 ? i : f[j]); } f[i] = i; } } // 素数判定 : O(1) bool isPrime(int x){return f[x] == x;} // 素因数分解 : O(log(n)) vector> prime_factor(int x){ if(x == 1)return {}; vector> ret; ret.emplace_back(f[x], 1); x /= f[x]; while(x != 1){ if(f[x] == ret.back().first){ ret.back().second++; }else{ ret.emplace_back(f[x], 1); } x /= f[x]; } return ret; } }; int main(){ int n; cin >> n; vector a(n); rep(i, n)cin >> a[i]; set pf; smart_sieve ss(200000); rep(i, n){ vector> p; p = ss.prime_factor(a[i]); for(auto x : p)pf.insert(x.first); } int cnt = 0, mn = mod; vector pos(200000, -1); for(auto it = pf.begin(); it != pf.end(); it++){ mn = (mn == mod ? (*it) : mn); pos[*it] = cnt++; } dsu uf(n+cnt); rep(i, n){ vector> p; p = ss.prime_factor(a[i]); for(auto x : p)uf.merge(i, n+pos[x.first]); } set st; rep(i, n)st.insert(uf.leader(i)); int ans = mod, S = st.size(); if(pos[2] == -1){ ans = mn*(S-1); }else{ ans = 2 * (S-1); } cout << ans << endl; }