#include using namespace std; template bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0;} using ll = long long; const ll amax = 1e5 + 100; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ll N; cin >> N; vector A(N); for (auto &a : A) cin >> a; vector uniq; vector cnt(amax, 0); ll res = 0; for (auto a : A) { if (cnt[a] == 0) uniq.emplace_back(a); else res += a; cnt[a] += 1; } sort(uniq.begin(), uniq.end()); vector> vec(amax); const ll INF = 1e18; for (auto a : uniq) { vector divisor; for (int i = 1; i * i <= a; ++i) { if (a % i == 0) { divisor.emplace_back(i); if (a / i != i) divisor.emplace_back(a / i); } } ll mn = INF; for (auto d : divisor) { if (vec[d].size() == 0) { vec[d].emplace_back(a); continue; } ll t = vec[d][0]; chmin(mn, lcm(a, t)); vec[d].emplace_back(a); } // cout << a << " " << mn << endl; if (mn == INF) continue; res += mn; } cout << res << endl; return 0; }