#include #include #include #include void factorize(unsigned long long n, std::multiset& result) { while (n % 2 == 0) { result.insert(2); n /= 2; } for (unsigned long long i = 3; i <= sqrt(n); i += 2) { while (n % i == 0) { result.insert(i); n /= i; } } if (n > 2) { result.insert(n); } } int main() { int n; std::cin >> n; std::multiset factorization; unsigned long long total_sum = 0; for (int i = 0; i != n; ++i) { unsigned long long stick; std::cin >> stick; factorization.clear(); factorize(stick, factorization); unsigned long long p = 1; unsigned long long sum = p; for (auto i = factorization.rbegin(); i != factorization.rend(); ++i) { p *= *i; sum += p; } total_sum += sum; } std::cout << total_sum << std::endl; return 0; }