#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

map<ll, ll> m;
map<ll, ll> ps;

ll f(ll n){
	if(n == 1) return 1;
	if(m.count(n)) return m[n];
	ll ret = n + 1;
	for(auto pp : ps){
		if(pp.second == 0) continue;
		ps[pp.first]--;
		ll n1 = n / pp.first, n2 = pp.first;
		ret = max(ret, f(n1) * n2 + 1);
		ps[pp.first]++;
	}
	/*for(ll i = 2; i * i <= n; i++){
		if(n % i == 0){

			ll n1 = n / i, n2 = i;
			x[n2] = f(n1) * n2 + 1;
			x[n1] = f(n2) * n1 + 1;
			ret = max(ret, f(n1) * n2 + 1);
			ret = max(ret, f(n2) * n1 + 1);
		}
	}*/
	return m[n] = ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int n;
	cin >> n;

	ll sum = 0;
	for(int i = 0; i < n; i++){
		ll l;
		cin >> l;
		ll tmp = l;
		ps.clear();
		for(ll i = 2; i * i <= l; i++){
			while(tmp % i == 0){
				tmp /= i;
				ps[i]++;
			}
		}
		if(tmp != 1) ps[tmp]++;
		sum += f(l);
	}
	cout << sum << endl;
}