#include <bits/stdc++.h>

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 1000179;
bool np[N];
vector<int> ps;

ll solve(ll a) {
    ll ans = a;
    ll cc = 1;
    vector<ll> q;
    for (int i : ps) {
        while (a % i == 0) {
            //ans += cc;
            //cc *= i;
            //a /= i;
            a /= i;
            q.push_back(i);
        }
    }
    if (a != 1)
        q.push_back(a);
    sort(ALL(q), greater<ll>());
    for (ll i : q) {
        ans += cc;
        cc *= i;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    
    for (int i = 2; i < N; ++i)
        if (!np[i]) {
            ps.push_back(i);
            for (int j = i; j < N; j += i)
                np[j] = 1;
        }
    reverse(ALL(ps));

    int n;
    cin >> n;
    ll q = 0;
    while (n--) {
        ll a;
        cin >> a;
        q += solve(a);
    }
    cout << q << "\n";

    return 0;
}