#include #define pb push_back using namespace std; long long primes[80000]; long long counter = -1; bool isPrime(long long x) { for (int i = 2; i*i <= x; i++) { if (x % i == 0) return false; } return true; } long long getMoves(long long x) { if (x == 1) return 1; vector dividePrimes; if (binary_search(primes, primes + counter, x)) { dividePrimes.pb(x); x = 1; } else { long long startingX = sqrt(x) + 1; for (int i = 0; primes[i] <= startingX && x > 1 && i <= counter; i++) { while (x % primes[i] == 0) { dividePrimes.pb(primes[i]); x /= primes[i]; } } } if (x > 1) dividePrimes.pb(x); sort(dividePrimes.begin(), dividePrimes.end()); long long result = 0, parts = 1; for (long long i = dividePrimes.size() - 1; i >= 0; i--) { result += parts; parts *= dividePrimes[i]; } result += parts; return result; } int main() { ios_base::sync_with_stdio(0); // preprocess primes for (int i = 2; i <= 1000000; i++) if (isPrime(i)) { counter++; primes[counter] = i; } long long n, a; long long exit = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a; exit += getMoves(a); } cout << exit << "\n"; }