#include #include #include #include #include #include #include using namespace std; long long ipow(long long n, int k) { long long z = 1LL; for (int i = 0; i < k; i++) { z *= n; } return z; } long long powmod(long long a, long long b, long long n) { if (b == 0LL) { return 1LL; } else { auto z = powmod(a, b >> 1LL, n); z = z * z % n; if (b % 2LL) { z = z * a % n; } return z; } } int millerRabin(long long n) { long long d = n - 1; int s = 0; while (d & 1LL) { d >>= 1LL; s += 1; } long long as[] = {2, 13, 23, 1662803}; for (auto a : as) { if (powmod(a, d, n) == 1LL) { continue; } int r; for (r = 0; r < s; r++) { if (powmod(a, (1LL << r) * d, n) == n - 1LL) { break; } } if (r == s) { return false; } } return true; } map factor(long long n) { map ps; auto m = n; while (m % 2LL == 0LL) { m >>= 1; ps[2] += 1; } if (m > 1LL && millerRabin(m)) { ps[m] += 1; m = 1LL; } for (long long i = 3; i * i <= m; ) { if (m % i == 0LL) { ps[i] += 1; m /= i; } else { i++; } } if (m != 1) { ps[m] += 1; } return ps; } vector divisors(map ps) { vector ds; if (ps.size()) { auto z = *ps.begin(); ps.erase(z.first); for (int i = 0; i <= z.second; i++) { for (auto w : divisors(ps)) { ds.push_back(ipow(z.first, i) * w); } } } else { ds.push_back(1LL); } return ds; } /* map zs; long long f(long long n) { if (n == 1LL) return 1LL; if (!zs.count(n)) { long long max_z = -1LL; auto ps = factor(n); //auto ds = divisors(ps); for (auto z2 : ps) { auto d = z2.first; long long z = d == 1LL ? 1LL : d * f(n / d) + 1LL; max_z = max(max_z, z); } zs[n] = max_z; } return zs[n]; } */ long long f(long long n) { auto ps = factor(n); long long sum = n; long long q = 1LL; for (auto z : ps) { for (int i = 0; i < z.second; i++) { q *= z.first; sum += n / q; } } return sum; } int main() { int n; cin >> n; long long sum = 0; for (int i = 0; i < n; i++) { long long a; cin >> a; sum += f(a); } cout << sum << endl; /* { long long w = 1000000000000; cout << f(w) << endl; cout << millerRabin(w) << endl; auto ps = factor(w); for (auto z : ps) cout << z.first << ":" << z.second << " "; cout << endl; auto ds = divisors(factor(w)); for (auto p : ds) cout << p << " "; cout << endl; } */ return 0; }