#include #include #include #include using namespace std; vector primes; long long get(long long x) { long long ans = 0; long long mul = 1; long long xx = x; long long xxx = x; for (int i = primes.size() - 1; i >= 0; --i) { long long div = primes[i]; while (x % div == 0) x /= div; } if (x != 1) { xx /= x; ans = 1; mul = x; } x = xx; for (int i = primes.size() - 1; i >= 0; --i) { long long div = primes[i]; while (x % div == 0) { ans += mul; mul *= div; x /= div; } } return ans + xxx; } int main() { int n; cin >> n; vector is_prime(2000000, 1); for (int i = 2; i < is_prime.size(); ++i) { if (!is_prime[i]) continue; primes.push_back(i); for (int j = 2 * i; j < is_prime.size(); j += i) is_prime[j] = 0; } long long sum = 0; for (int i = 0; i < n; ++i) { long long x; cin >> x; sum += get(x); } cout << sum << endl; system("pause"); return 0; }