#include #include using namespace std; typedef long long ll; map z; ll calc(ll x) { if (x == 1) return 1; if (z.count(x)) return z[x]; ll e = x; ll p = 1+x; for (ll u = 2; u*u <= e; u++) { if (e%u == 0) { p = max(p,1+u*calc(x/u)); } while (e%u == 0) e /= u; } if (e != 1) p = max(p,1+e*calc(x/e)); z[x] = p; return p; } int main() { int n; cin >> n; ll u = 0; while (n--) { ll x; cin >> x; u += calc(x); } cout << u << "\n"; }