#include using namespace std; const int MAX = 100001; struct unionfind{ vector p; unionfind(int N){ p = vector(N, -1); } int root(int x){ if (p[x] < 0){ return x; } else { p[x] = root(p[x]); return p[x]; } } bool same(int x, int y){ return root(x) == root(y); } void unite(int x, int y){ x = root(x); y = root(y); if (x != y){ if (p[x] < p[y]){ swap(x, y); } p[y] += p[x]; p[x] = y; } } }; int main(){ int N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector cnt(MAX, 0); for (int i = 0; i < N; i++){ cnt[A[i]]++; } vector> E; for (int i = 1; i < MAX; i++){ vector p; for (int j = i; j < MAX; j += i){ if (cnt[j] > 0){ p.push_back(j); } } if (p.size() >= 2){ int cnt2 = p.size(); for (int j = 1; j < cnt2; j++){ long long c = (long long) p[0] * p[j] / i; E.push_back(make_tuple(c, p[0], p[j])); } } } sort(E.begin(), E.end()); int M = E.size(); unionfind UF(MAX); long long ans = 0; for (int i = 0; i < M; i++){ int u = get<1>(E[i]); int v = get<2>(E[i]); if (!UF.same(u, v)){ UF.unite(u, v); ans += get<0>(E[i]); } } for (int i = 0; i < MAX; i++){ if (cnt[i] >= 2){ ans += (long long) i * (cnt[i] - 1); } } cout << ans << endl; }