#include #include #include #include #include #include #include long long maxPrimeFactors(long long n) { // Initialize the maximum prime factor // variable with the lowest one long long maxPrime = -1; // Print the number of 2s that divide n while (n % 2 == 0) { maxPrime = 2; n >>= 1; // equivalent to n /= 2 } // n must be odd at this point, thus skip // the even numbers and iterate only for // odd integers for (int i = 3; i <= sqrt(n); i += 2) { while (n % i == 0) { maxPrime = i; n = n / i; } } // This condition is to handle the case // when n is a prime number greater than 2 if (n > 2) maxPrime = n; return maxPrime; } int main() { long int n,k,sum=0,z,c=1; scanf("%i", &n); long int *a = malloc(sizeof(long int) * n); for (int a_i = 0; a_i < n; a_i++) { c=1; scanf("%li",&a[a_i]); z=a[a_i]; while(z>1){ k=maxPrimeFactors(z); sum=sum+c*k; c=c*k; z=z/k; } } printf("%ld\n", sum+n); return 0; }