#include #include #include #include #include #include using namespace std; unordered_map DP; bool isPrime(long long a){ for (long long i=2; i*i<=a; i++) if (a%i==0) return false; return true; } long long getPrimeFactors(long long a) { long long lastPrime; int base = 2 ; while(true){ if (a==1 || isPrime(a)){ return a; } if (a % base == 0){ lastPrime = base; while( a>base && a%base == 0){ a/=base; } }else { base++; } } return lastPrime; } long long getMaxMoves(long long a){ if (a==1) return 1; if (isPrime(a)) return a+1; if (DP.count(a)) return DP[a]; long long greatestPrime = getPrimeFactors(a); long long maxMoves = greatestPrime * getMaxMoves(a / greatestPrime) + 1; DP[a] = maxMoves; return maxMoves; } int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } /* Enter your code here. Print output to STDOUT */ long long moves = 0; for (int i=0; i < n; i++) { moves += getMaxMoves(a[i]); } cout << moves << endl; return 0; }