#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #include using std::cerr; using std::cin; using std::cout; using std::abs; using std::min; using std::max; using std::swap; using std::map; using std::pair; using std::set; using std::string; using std::vector; using ll = long long; using uint = unsigned int; using pii = pair; using pll = pair; #define ff first #define ss second #define pb emplace_back template void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h <<"\n"; } template void _dbg(const char* _s, T _h, Ts... _t) { int _b = 0; while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',') cerr << *_s++; cerr << " = " << _h << ","; _dbg(_s+1, _t...); } #ifdef LOCAL #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__) #else #define dbg(...) #endif struct init { init() { cin.tie(0); std::iostream::sync_with_stdio(0); cout << std::fixed << std::setprecision(10); cerr << std::fixed << std::setprecision(5); #ifdef LOCAL srand(300); #else using namespace std::chrono; srand(duration_cast(high_resolution_clock::now().time_since_epoch()).count()); #endif } ~init() { #ifdef LOCAL cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n"; #endif } } init; const int MAXN = 100; int a[MAXN]; void primes(int n, vector & pr, vector & lp) { lp.assign(n + 1, 0); pr.clear(); for (int i = 2; i <= n; ++i) { if (lp[i] == 0) { lp[i] = i; pr.pb(i); } for (uint j = 0; j < pr.size() && pr[j] <= lp[i] && i * pr[j] <= n; ++j) lp[i * pr[j]] = pr[j]; } } vector pr, lp; int main() { primes(1000017, pr, lp); int n; cin >> n; ll ans = 0; for (int i = 0; i < n; ++i) { ll x; cin >> x; vector prm; for (ll j : pr) { if (j > x) break; while (x%j==0) { prm.pb(j); x/=j; } } if (x != 1) prm.pb(x); sort(prm.begin(), prm.end(), std::greater()); ll mul = 1; for (ll d : prm) { ans += mul; mul *= d; } ans += mul; } cout << ans << '\n'; return 0; }