/*Problem Link : https://www.hackerrank.com/contests/world-codesprint-12/challenges/breaking-sticks */ //Author : herambpatil98 #include #define mod 1000000000 using namespace std; typedef long long ll; int main(int argc, char const *argv[]) { ll i, n, arr[105], flag; ll ans, count, temp, d, j, m; vector pf; scanf("%lld", &n); for(i = 0; i < n; i++) scanf("%lld", &arr[i]); ans = 0; for(i = 0; i < n; i++){ temp = arr[i]; count = 1; pf.clear(); //Prime factor /*m = 1; for(j = sqrt(temp) + 1; j >= 1; j--){ if(temp == 1){ ans += m; break; } if(temp % j == 0){ ans += m; m *= j; temp /= j; while(temp % j == 0 && temp > 0){ ans += m; m *= j; temp /= j; } } }*/ flag = 0; if(temp == 1){ ans++; continue; } while(temp % 2 == 0) { //printf("%d ", 2); pf.push_back(2); temp = temp/2; } for (j = 3; j <= sqrt(temp); j = j + 2) { // While i divides n, print i and divide n while (temp % j == 0) { //printf("%lld ", i); pf.push_back(j); temp = temp / j; } } if (temp > 2){ //printf ("%lld ", temp); pf.push_back(temp); } reverse(pf.begin(), pf.end()); for(j = 0; j < pf.size(); j++){ ans += count; count *= pf[j]; } ans += count; } printf("%lld\n", ans); return 0; }