#include using namespace std; //*/ #include using namespace atcoder; //*/ #define rep(i,n) for(int i=0;i; using ll = long long; using ull = unsigned long long; //*/ template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef pair pii; typedef pair pll; typedef vector vll; typedef vector vint; random_device rnd; mt19937 rng(rnd()); vector divisor(long long n) { vector ret; for (long long i = 1; i*i <= n; i++) { if (n % i == 0) { ret.push_back(i); if(n/i != i) ret.push_back(n/i); } } sort(ret.begin(),ret.end()); return ret; } struct UnionFind { vector par; UnionFind(int n=0): par(n,-1) {} int find(int x) { if(par[x] < 0) return x; return par[x] = find(par[x]); } bool unite(int x, int y){ x = find(x); y = find(y); if(x==y) return false; if(par[x] > par[y]) swap(x,y); par[x] += par[y]; par[y] = x; return true; } bool same(int x, int y) {return find(x) == find(y);} int size(int x) {return -par[find(x)];} }; void solve(){ int n; cin >> n; vint a(n); rep(i,n) cin >> a[i]; auto v = divisor(a[0]); reverse(ALL(v)); v.pop_back(); map mp; int cnt = n; for(ll x : v) mp[x] = ++cnt; ll sz = n+1+v.size(); UnionFind dsu(sz); rep(i,n){ for(ll x : v)if(a[i]%x==0) dsu.unite(i,mp[x]); } dsu.unite(n,0); ll c = sz-dsu.size(0); cout << v.back()*c << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; //cin >> t; rep(testcases,t) solve(); }