#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double T;
typedef vector<T> VT;
typedef vector<VT> VVT;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> PI;
typedef vector<PI> VPI;

const ll MOD = 1e9 + 7;
const double EPS = 1e-10;

unordered_map<ll, ll> dp;

VI primes;
const ll M = 1e6;
bool sieve [M+1];

VI divs;

ll f(ll k) {
    if (k == 1)
        return 0;
    if (dp.find(k) != dp.end())
        return dp[k];

    ll ans = 0;
    for (ll p : divs) {
        if (k%p == 0)
            ans = max(ans, 1 + p*f(k/p));
    }
    return dp[k] = ans;
}

ll pw (ll b, ll e) {
    ll r = 1;
    while (e--)
        r *= b;
    return r;
}

void gendivs(VPI pdivs, ll ind, ll cur) {
    if (ind == pdivs.size()) {
        if (cur > 1)
            divs.push_back(cur);
        return;
    }
    for (ll i = 0; i <= pdivs[ind].second; ++i) {
        gendivs(pdivs, ind+1, cur*pw(pdivs[ind].first, i));
    }
}

int main() {
    for (ll i = 2; i <= M; ++i) {
        if (sieve[i])
            continue;
        primes.push_back(i);
        for (ll j = i*i; j <= M; j += i)
            sieve[j] = 1;
    }

    ll n;
    cin >> n;
    ll tot = 0;
    while (n--) {
        ll k;
        cin >> k;
        divs.clear();
        VPI pdivs;
        ll kk = k;
        for (ll p : primes) {
            ll c = 0;
            while (kk % p == 0) {
                ++c;
                kk /= p;
            }
            if (c > 0) {
                pdivs.push_back(make_pair(p, c));
            }
        }
        if (kk != 1)
            pdivs.push_back(make_pair(kk, 1));

        gendivs(pdivs, 0, 1);
        tot += k + f(k);
    }
    cout << tot << "\n";
}