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

typedef long long ll;

const int SITO_MAX = 1000005;

int f[SITO_MAX+1];
vector<int> prosti;

struct sito {
	sito() {
		for (int i=2; i<=SITO_MAX; i++) {
			if (f[i] == 0) {
				f[i] = i;
				prosti.push_back(i);
			}
			int j = 0;
			while (j < (int)prosti.size()) {
				if (prosti[j] > f[i]) {
					break;
				}
				int x = i * prosti[j];
				if (x > SITO_MAX) {
					break;
				}
				f[x] = prosti[j];
				j++;
			}
		}
	}
} sito_obj_983431;

vector<pair<ll, int>> faktorisi(ll x) {
	vector<pair<ll, int>> v;
	for (int p : prosti) {
		if (x % p == 0) {
			int c = 0;
			while (x % p == 0) {
				c++;
				x /= p;
			}
			v.push_back({p, c});
		}
	}
	if (x > 1) {
		v.push_back({x, 1});
	}
	return v;
}

ll resi(ll x) {
	auto v = faktorisi(x);
	reverse(v.begin(), v.end());
	ll y = 0, p = 1;
	for (auto& e : v) {
		while (e.second > 0) {
			y += p;
			p *= e.first;
			e.second--;
		}
	}
	return y + p;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	int n;
	cin >> n;
	ll sol = 0;
	while (n--) {
		ll x;
		cin >> x;
		sol += resi(x);
	}
	cout << sol << '\n';
}